Files
docx-js/docs/usage/document.md
Eli Flanagan 249e44532f add documentation on positioning units
See further discussions in #50, #191.
2018-12-11 16:49:18 -05:00

1.1 KiB

Document

The Document object is the starting point of your .docx journey, this is the literal Word Document. You add all your content such as Paragraphs to this Document, and at the end export it however you like.

To create a new document, it is very easy:

const doc = new docx.Document();

Document properties

You can add properties to the Word document by specifying options, for example:

const doc = new docx.Document({
    creator: "Dolan Miu",
    description: "My extremely interesting document",
    title: "My Document",
});

Full list of options:

  • creator
  • description
  • title
  • subject
  • keywords
  • lastModifiedBy
  • revision

You can mix and match whatever properties you want, or provide no properties.

units for positioning

Various parts of the API require positioning arguments. The units are "20ths of a point" from the OOXML specification. See Lars Corneliussen's blog post for more information and how to convert units.