docx
    Preparing search index...

    Class File

    Represents a Word document file.

    The File class (exported as Document) is the main entry point for creating DOCX documents. It manages all document components including content, styles, numbering, headers/footers, and media. Documents are organized into sections, each of which can have its own page settings, headers, and footers.

    This class handles the assembly of all OOXML parts required for a valid .docx file, including relationships, content types, and document properties.

    // Simple document with one section
    const doc = new Document({
    sections: [{
    children: [
    new Paragraph("Hello World"),
    ],
    }],
    });

    // Document with multiple sections and headers/footers
    const doc = new Document({
    creator: "John Doe",
    sections: [
    {
    headers: {
    default: new Header({
    children: [new Paragraph("Header Text")],
    }),
    },
    children: [
    new Paragraph("Section 1 content"),
    ],
    },
    {
    children: [
    new Paragraph("Section 2 content"),
    ],
    },
    ],
    });

    // Document with custom styles and numbering
    const doc = new Document({
    styles: {
    paragraphStyles: [
    {
    id: "MyHeading",
    name: "My Heading",
    basedOn: "Heading1",
    run: { bold: true, color: "FF0000" },
    },
    ],
    },
    numbering: {
    config: [
    {
    reference: "my-numbering",
    levels: [
    { level: 0, format: "decimal", text: "%1.", alignment: "left" },
    ],
    },
    ],
    },
    sections: [{
    children: [new Paragraph("Content")],
    }],
    });
    Index

    Constructors

    Accessors

    • get AppProperties(): AppProperties

      Returns AppProperties

    • get CoreProperties(): CoreProperties

      Returns CoreProperties

    • get CustomProperties(): CustomProperties

      Returns CustomProperties

    • get Document(): DocumentWrapper

      Returns DocumentWrapper

    • get Endnotes(): EndnotesWrapper

      Returns EndnotesWrapper

    • get FileRelationships(): Relationships

      Returns Relationships

    • get FootNotes(): FootnotesWrapper

      Returns FootnotesWrapper