DOCX
Document Properties
Set core, extended (app), and custom document properties
Core Properties
Core metadata is written to docProps/core.xml and read back on parse. Set these fields directly on the document options:
{
"title": "Quarterly Report",
"subject": "Finance",
"creator": "Jane Doe",
"keywords": "q4, finance",
"description": "Quarterly financial report",
"revision": 2,
"sections": []
}
import { generateDocument } from "@office-open/docx";
const buffer = await generateDocument({
title: "Quarterly Report",
subject: "Finance",
creator: "Jane Doe",
keywords: "q4, finance",
description: "Quarterly financial report",
revision: 2,
sections: [
/* … */
],
});
| Property | Type | Description |
|---|---|---|
title | string | Document title |
subject | string | Subject |
creator | string | Author |
keywords | string | Keywords |
description | string | Description |
lastModifiedBy | string | Last modifier |
revision | number | Revision number |
lastPrinted | string | Last printed date (W3CDTF) |
created | string | Creation date (W3CDTF) |
modified | string | Last modified date (W3CDTF) |
Extended Properties
appProperties are written to docProps/app.xml. The commonly user-set fields are template, manager, company, and application; the rest (pages, words, characters, …) are document statistics typically computed by Office:
{
"appProperties": { "company": "Globex", "manager": "Jane Doe" },
"sections": []
}
import { generateDocument } from "@office-open/docx";
const buffer = await generateDocument({
appProperties: {
company: "Globex",
manager: "Jane Doe",
template: "report.dotx",
application: "office-open",
},
sections: [
/* … */
],
});
| Property | Type | Description |
|---|---|---|
template | string | Template name |
manager | string | Manager name |
company | string | Company name |
application | string | Application name |
appVersion | string | Application version |
pages | number | Page count |
words | number | Word count |
characters | number | Character count |
lines | number | Line count |
paragraphs | number | Paragraph count |
totalTime | number | Total editing time (min) |
hyperlinkBase | string | Hyperlink base URL |
docSecurity | number | Document security level |
Custom Properties
customProperties are written to docProps/custom.xml. Each value is a string:
{
"customProperties": [
{ "name": "ProjectId", "value": "PRJ-42" },
{ "name": "Department", "value": "Finance" }
],
"sections": []
}
import { generateDocument } from "@office-open/docx";
const buffer = await generateDocument({
customProperties: [
{ name: "ProjectId", value: "PRJ-42" },
{ name: "Department", value: "Finance" },
],
sections: [
/* … */
],
});
| Property | Type | Description |
|---|---|---|
name | string | Property name |
value | string | Property value |