-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Missing text property for patchDocument (#2760)
* fix: Missing text property Ignore <br /> for patched files * Fix spelling issues
- Loading branch information
Showing
7 changed files
with
751 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Patch a document with patches | ||
|
||
import * as fs from "fs"; | ||
import { patchDocument, PatchType, TextRun } from "docx"; | ||
|
||
patchDocument({ | ||
outputType: "nodebuffer", | ||
data: fs.readFileSync("demo/assets/field-trip.docx"), | ||
patches: { | ||
todays_date: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: new Date().toLocaleDateString() })], | ||
}, | ||
|
||
school_name: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
address: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "blah blah" })], | ||
}, | ||
|
||
city: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
state: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
zip: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
phone: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
first_name: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
last_name: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
email_address: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
ft_dates: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
|
||
grade: { | ||
type: PatchType.PARAGRAPH, | ||
children: [new TextRun({ text: "test" })], | ||
}, | ||
}, | ||
}).then((doc) => { | ||
fs.writeFileSync("My Document.docx", doc); | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.