docx
    Preparing search index...

    Module index

    Main entry point for the docx library.

    This module provides a declarative API for creating .docx files that works in both Node.js and browser environments. The library generates documents compliant with the OOXML (Office Open XML) specification.

    The primary export is the Document class (internally named File), which serves as the main entry point for creating Word documents.

    import { Document, Paragraph, TextRun, Packer } from "docx";

    // Create a document
    const doc = new Document({
    sections: [{
    children: [
    new Paragraph({
    children: [
    new TextRun({ text: "Hello World", bold: true }),
    ],
    }),
    ],
    }],
    });

    // Export to buffer
    const buffer = await Packer.toBuffer(doc);
    NumberedItemReferenceFormat
    VerticalAnchor
    AbstractNumbering
    AnnotationReference
    Attributes
    BaseXmlComponent
    Body
    Bookmark
    BookmarkEnd
    BookmarkStart
    Border
    BuilderElement
    CarriageReturn
    CellMerge
    CellMergeAttributes
    CheckBox
    CheckBoxSymbolElement
    CheckBoxUtil
    Column
    ColumnBreak
    Comment
    CommentRangeEnd
    CommentRangeStart
    CommentReference
    Comments
    CommentsExtended
    CommentsIds
    ConcreteNumbering
    ContinuationSeparator
    DayLong
    DayShort
    DeletedTableCell
    DeletedTableRow
    DeletedTextRun
    DocumentAttributes
    DocumentBackground
    DocumentBackgroundAttributes
    DocumentDefaults
    Drawing
    DrawingPatch
    EmptyElement
    EndnoteIdReference
    EndnoteReference
    EndnoteReferenceRun
    EndnoteReferenceRunAttributes
    Endnotes
    File
    FileChild
    FooterWrapper
    FootnoteReference
    FootnoteReferenceElement
    FootnoteReferenceRun
    FootNoteReferenceRunAttributes
    FootNotes
    GridSpan
    HeaderWrapper
    HpsMeasureElement
    IgnoreIfEmptyXmlComponent
    ImageRun
    ImportedRootElementAttributes
    ImportedXmlComponent
    InitializableXmlComponent
    InsertedTableCell
    InsertedTableRow
    InsertedTextRun
    LastRenderedPageBreak
    Level
    LevelBase
    LevelForOverride
    LevelOverride
    Math
    MathAngledBrackets
    MathCurlyBrackets
    MathDegree
    MathDenominator
    MathFraction
    MathFunction
    MathFunctionName
    MathFunctionProperties
    MathIntegral
    MathLimit
    MathLimitLower
    MathLimitUpper
    MathNumerator
    MathPreSubSuperScript
    MathRadical
    MathRadicalProperties
    MathRoundBrackets
    MathRun
    MathSquareBrackets
    MathSubScript
    MathSubSuperScript
    MathSum
    MathSuperScript
    Media
    MonthLong
    MonthShort
    NextAttributeComponent
    NoBreakHyphen
    NonVisualDrawingProperties
    NumberedItemReference
    Numbering
    NumberProperties
    NumberValueElement
    OnOffElement
    PackagePart
    Packer
    PageBorders
    PageBreak
    PageBreakBefore
    PageNumberElement
    PageReference
    PageTextDirection
    Paragraph
    ParagraphProperties
    ParagraphPropertiesChange
    ParagraphPropertiesDefaults
    ParagraphRunProperties
    PositionalTab
    Run
    RunProperties
    RunPropertiesChange
    RunPropertiesDefaults
    SectionProperties
    SectionPropertiesChange
    Separator
    SequentialIdentifier
    SimpleField
    SimpleMailMergeField
    SoftHyphen
    StringContainer
    StringEnumValueElement
    StringValueElement
    StyleForCharacter
    StyleForParagraph
    StyleLevel
    Styles
    SymbolRun
    Tab
    Table
    TableBorders
    TableCell
    TableCellBorders
    TableOfContents
    TableProperties
    TableRow
    TableRowProperties
    TableRowPropertiesChange
    TDirection
    Textbox
    TextRun
    ThematicBreak
    Theme
    VerticalMerge
    WpgGroupRun
    WpsShapeRun
    XmlAttributeComponent
    XmlComponent
    YearLong
    YearShort
    IXmlableObject
    AttributeData
    AttributeMap
    AttributePayload
    DocPropertiesOptions
    DocumentAttributeNamespace
    DrawingLinkOptions
    EffectExtentAttributes
    EmbeddedPackageFile
    EstimatedPageNumbers
    GraphicMediaData
    IAlignmentFrameOptions
    IBaseCharacterStyleOptions
    IBaseParagraphStyleOptions
    IBodyOptions
    IBodyPropertiesOptions
    IBookmarkOptions
    IBorderOptions
    IBordersOptions
    ICellMergeAttributes
    ICharacterStyleOptions
    ICheckboxSymbolOptions
    ICheckboxSymbolProperties
    IColumnAttributes
    IColumnsAttributes
    ICommentIdData
    ICommentOptions
    ICommentsOptions
    ICommentThreadData
    IConcreteNumberingOptions
    IContext
    ICropOptions
    IDistance
    IDocGridAttributesProperties
    IDocumentAttributesProperties
    IDocumentBackgroundOptions
    IDocumentDefaultsOptions
    IDocumentFooter
    IDocumentHeader
    IDocumentOptions
    IDrawingOptions
    IExtendedMediaData
    IExternalHyperlinkOptions
    IFloating
    IFontAttributesProperties
    IFrameOptions
    IGroupChildMediaData
    IHeaderFooterGroup
    IHeaderFooterOptions
    IHeaderOptions
    IHorizontalPositionOptions
    IImageOptions
    IIndentAttributesProperties
    IInternalHyperlinkOptions
    ILevelParagraphStylePropertiesOptions
    ILevelsOptions
    ILineNumberAttributes
    IMargins
    IMathFractionOptions
    IMathFunctionOptions
    IMathIntegralOptions
    IMathLimitLowerOptions
    IMathLimitUpperOptions
    IMathOptions
    IMathPreSubSuperScriptOptions
    IMathRadicalOptions
    IMathSubScriptOptions
    IMathSubSuperScriptOptions
    IMathSumOptions
    IMathSuperScriptOptions
    IMediaData
    IMediaDataTransformation
    IMediaTransformation
    InputDataType
    INumberedItemReferenceOptions
    INumberingOptions
    IPageBorderAttributes
    IPageBordersOptions
    IPageMarginAttributes
    IPageNumberTypeAttributes
    IPageReferenceOptions
    IPageSizeAttributes
    IParagraphOptions
    IParagraphPropertiesChangeOptions
    IParagraphPropertiesConfig
    IParagraphPropertiesOptions
    IParagraphPropertiesOptionsBase
    IParagraphRunOptions
    IParagraphRunPropertiesOptions
    IParagraphStyleOptions
    IParagraphStylePropertiesOptions
    IPatch
    IPropertiesOptions
    IRunOptions
    IRunPropertiesChangeOptions
    IRunPropertiesOptions
    IRunStylePropertiesOptions
    ISectionOptions
    ISectionPropertiesChangeOptions
    ISectionPropertiesOptions
    ISectionPropertiesOptionsBase
    IShadingAttributesProperties
    ISpacingProperties
    IStylesOptions
    ISymbolRunOptions
    ITableBordersOptions
    ITableCellBorders
    ITableCellOptions
    ITableFloatOptions
    ITableLookOptions
    ITableOfContentsOptions
    ITableOptions
    ITablePropertiesChangeOptions
    ITablePropertiesOptions
    ITablePropertiesOptionsBase
    ITableRowOptions
    ITableRowPropertiesChangeOptions
    ITableRowPropertiesOptions
    ITableRowPropertiesOptionsBase
    ITableWidthProperties
    ITextWrapping
    IThemeColorsOptions
    IThemeFontOptions
    IThemeFontReference
    IThemeFontsOptions
    IThemeOptions
    IVerticalPositionOptions
    IVmlShapeOptions
    IWpgGroupOptions
    IWpsShapeOptions
    IXmlAttribute
    IXYFrameOptions
    LengthUnit
    MathComponent
    MathFractionType
    MathLimitsPosition
    MathRunOptions
    MathRunScript
    MathRunStyle
    NonVisualDrawingPropertiesOptions
    OutputByType
    OutputType
    PackagePartOptions
    PageNumberEstimator
    ParagraphChild
    PatchDocumentOptions
    PatchDocumentOutputType
    PatchedTemplate
    Percentage
    PositionalTabOptions
    PositivePercentage
    PositiveUniversalMeasure
    RelationshipType
    RelativeMeasure
    SectionVerticalAlign
    TableRowsPatch
    TableVerticalAlign
    TabStopDefinition
    TemplateDrawing
    TemplatePackage
    TemplatePageNumberEstimator
    TemplatePart
    ThemeColor
    ThemeColorName
    ThemeFont
    UniqueNumericIdCreator
    UniversalMeasure
    VmlShapeStyle
    WpgCommonMediaData
    WpgMediaData
    WpsMediaData
    AlignmentType
    bookmarkUniqueNumericId
    BorderStyle
    CharacterSet
    docPropertiesUniqueNumericId
    DocumentAttributeNamespaces
    DocumentGridType
    DropCapType
    eighthPointMeasureValue
    EmphasisMarkType
    EMPTY_OBJECT
    FrameAnchorType
    FrameWrap
    HeaderFooterReferenceType
    HeaderFooterType
    HeadingLevel
    HeightRule
    HighlightColor
    HorizontalPositionAlign
    HorizontalPositionRelativeFrom
    HyperlinkType
    LeaderType
    LevelFormat
    LevelSuffix
    LineNumberRestartFormat
    LineRuleType
    NumberFormat
    OverlapType
    PageBorderDisplay
    PageBorderOffsetFrom
    PageBorderZOrder
    PageNumber
    PageNumberSeparator
    PageOrientation
    PageTextDirectionType
    PatchType
    pointMeasureValue
    PositionalTabAlignment
    PositionalTabLeader
    PositionalTabRelativeTo
    PrettifyType
    RelativeHorizontalPosition
    RelativeVerticalPosition
    SchemeColor
    sectionMarginDefaults
    sectionPageSizeDefaults
    SectionType
    ShadingType
    SpaceType
    TableAnchorType
    TableLayoutType
    TabStopPosition
    TabStopType
    TextDirection
    TextEffect
    TextWrappingSide
    TextWrappingType
    UnderlineType
    VerticalAlign
    VerticalAlignSection
    VerticalAlignTable
    VerticalMergeRevisionType
    VerticalMergeType
    VerticalPositionAlign
    VerticalPositionRelativeFrom
    WidthType
    abstractNumUniqueNumericIdGen
    bookmarkUniqueNumericIdGen
    commentIdToParaId
    concreteNumUniqueNumericIdGen
    convertInchesToTwip
    convertMillimetersToTwip
    convertToXmlComponent
    createAlignment
    createBodyProperties
    createBorderElement
    createColumns
    createDocumentGrid
    createDotEmphasisMark
    createEmphasisMark
    createFrameProperties
    createHeaderFooterReference
    createHorizontalPosition
    createIndent
    createLineNumberType
    createMathAccentCharacter
    createMathBase
    createMathLimitLocation
    createMathNAryProperties
    createMathPreSubSuperScriptProperties
    createMathSubScriptElement
    createMathSubScriptProperties
    createMathSubSuperScriptProperties
    createMathSuperScriptElement
    createMathSuperScriptProperties
    createOutlineLevel
    createPageMargin
    createPageNumberType
    createPageSize
    createParagraphStyle
    createRunFonts
    createSectionType
    createShading
    createSimplePos
    createSpacing
    createStringElement
    createTableFloatProperties
    createTableLayout
    createTableLook
    createTableRowHeight
    createTableWidthElement
    createTabStop
    createTabStopItem
    createTransformation
    createUnderline
    createVerticalAlign
    createVerticalPosition
    createVmlShape
    createWrapNone
    createWrapSquare
    createWrapThrough
    createWrapTight
    createWrapTopAndBottom
    dateTimeValue
    decimalNumber
    docPropertiesUniqueNumericIdGen
    encodeUtf8
    fillPageNumbers
    fillPartPageNumbers
    hashedId
    hexColorValue
    hpsMeasureValue
    longHexNumber
    measurementOrPercentValue
    patchDetector
    patchDocument
    percentageValue
    positiveUniversalMeasureValue
    shortHexNumber
    signedHpsMeasureValue
    signedTwipsMeasureValue
    standardizeData
    twipsMeasureValue
    uCharHexNumber
    uniqueId
    uniqueNumericIdCreator
    uniqueUuid
    universalMeasureToTwips
    universalMeasureValue
    unsignedDecimalNumber
    Document → File