diff --git a/demo/54-custom-properties.ts b/demo/54-custom-properties.ts index f6ef7cf778..4aad3864c9 100644 --- a/demo/54-custom-properties.ts +++ b/demo/54-custom-properties.ts @@ -9,15 +9,20 @@ import { Document, Packer } from "../build"; const doc = new Document( // Standard properties - { creator: "Creator", title: "Title", subject: "Subject", description: "Description" }, + { + creator: "Creator", + title: "Title", + subject: "Subject", + description: "Description", + customProperties: [ + { name: "Subtitle", value: "Subtitle" }, + { name: "Address", value: "Address" }, + ], + }, // No file properties {}, // No sections [], - [ - { name: "Subtitle", value: "Subtitle" }, - { name: "Address", value: "Address" }, - ] ); Packer.toBuffer(doc).then((buffer) => { diff --git a/src/file/core-properties/properties.ts b/src/file/core-properties/properties.ts index 8e3921df0c..17a4baed2a 100644 --- a/src/file/core-properties/properties.ts +++ b/src/file/core-properties/properties.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "file/xml-components"; +import { ICustomPropertyOptions } from "../custom-properties"; import { IDocumentBackgroundOptions } from "../document"; import { DocumentAttributes } from "../document/document-attributes"; @@ -24,6 +25,7 @@ export interface IPropertiesOptions { readonly trackRevisions?: boolean; }; readonly compatabilityModeVersion?: number; + readonly customProperties?: ICustomPropertyOptions[]; } export class CoreProperties extends XmlComponent { diff --git a/src/file/file.ts b/src/file/file.ts index 2a1c294778..e91906f3d1 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -1,7 +1,7 @@ import { AppProperties } from "./app-properties/app-properties"; import { ContentTypes } from "./content-types/content-types"; import { CoreProperties, IPropertiesOptions } from "./core-properties"; -import { CustomProperties, ICustomPropertyOptions } from "./custom-properties"; +import { CustomProperties } from "./custom-properties"; import { DocumentWrapper } from "./document-wrapper"; import { FooterReferenceType, @@ -69,7 +69,6 @@ export class File { }, fileProperties: IFileProperties = {}, sections: ISectionOptions[] = [], - customProperties: ICustomPropertyOptions[] = [], ) { this.coreProperties = new CoreProperties(options); this.numbering = new Numbering( @@ -80,7 +79,7 @@ export class File { }, ); this.fileRelationships = new Relationships(); - this.customProperties = new CustomProperties(customProperties); + this.customProperties = new CustomProperties(options.customProperties ?? []); this.appProperties = new AppProperties(); this.footnotesWrapper = new FootnotesWrapper(); this.contentTypes = new ContentTypes();