Add custom properties demo
This commit is contained in:
25
demo/54-custom-properties.ts
Normal file
25
demo/54-custom-properties.ts
Normal file
@ -0,0 +1,25 @@
|
||||
// Custom Properties
|
||||
// Custom properties are incredibly useful if you want to be able to apply quick parts or custom cover pages
|
||||
// to the document in Word after the document has been generated. Standard properties (such as creator, title
|
||||
// and subject) cover typical use cases, but sometimes custom properties are required.
|
||||
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer } from "../build";
|
||||
|
||||
const doc = new Document(
|
||||
// Standard properties
|
||||
{ creator: "Creator", title: "Title", subject: "Subject", description: "Description" },
|
||||
// No file properties
|
||||
{},
|
||||
// No sections
|
||||
[],
|
||||
[
|
||||
{ name: "Subtitle", value: "Subtitle" },
|
||||
{ name: "Address", value: "Address" },
|
||||
]
|
||||
);
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
Reference in New Issue
Block a user