docx
    Preparing search index...

      docx

      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);

      Enumerations

      NumberedItemReferenceFormat
      VerticalAnchor

      Classes

      AbstractNumbering
      AnnotationReference
      Attributes
      BaseXmlComponent
      Body
      Bookmark
      BookmarkEnd
      BookmarkStart
      Border
      BuilderElement
      CarriageReturn
      CellMerge
      CellMergeAttributes
      CheckBox
      CheckBoxSymbolElement
      CheckBoxUtil
      Column
      ColumnBreak
      Comment
      CommentRangeEnd
      CommentRangeStart
      CommentReference
      Comments
      ConcreteNumbering
      ContinuationSeparator
      DayLong
      DayShort
      DeletedTableCell
      DeletedTableRow
      DeletedTextRun
      DocumentAttributes
      DocumentBackground
      DocumentBackgroundAttributes
      DocumentDefaults
      Drawing
      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
      NumberedItemReference
      Numbering
      NumberProperties
      NumberValueElement
      OnOffElement
      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
      VerticalMerge
      WpgGroupRun
      WpsShapeRun
      XmlAttributeComponent
      XmlComponent
      YearLong
      YearShort

      Interfaces

      IXmlableObject

      Type Aliases

      AttributeData
      AttributeMap
      AttributePayload
      DocumentAttributeNamespace
      IAlignmentFrameOptions
      IBaseCharacterStyleOptions
      IBaseParagraphStyleOptions
      IBodyPropertiesOptions
      IBookmarkOptions
      IBorderOptions
      IBordersOptions
      ICellMergeAttributes
      ICharacterStyleOptions
      ICheckboxSymbolOptions
      ICheckboxSymbolProperties
      IColumnAttributes
      IColumnsAttributes
      ICommentOptions
      ICommentsOptions
      IConcreteNumberingOptions
      IContext
      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
      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
      IVerticalPositionOptions
      IWpgGroupOptions
      IWpsShapeOptions
      IXmlAttribute
      IXYFrameOptions
      MathComponent
      OutputByType
      OutputType
      ParagraphChild
      PatchDocumentOptions
      PatchDocumentOutputType
      Percentage
      PositionalTabOptions
      PositivePercentage
      PositiveUniversalMeasure
      RelativeMeasure
      SectionVerticalAlign
      TableVerticalAlign
      TabStopDefinition
      UniqueNumericIdCreator
      UniversalMeasure
      WpgCommonMediaData
      WpgMediaData
      WpsMediaData

      Variables

      AlignmentType
      BorderStyle
      CharacterSet
      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
      sectionMarginDefaults
      sectionPageSizeDefaults
      SectionType
      ShadingType
      SpaceType
      TableAnchorType
      TableLayoutType
      TabStopPosition
      TabStopType
      TextDirection
      TextEffect
      TextWrappingSide
      TextWrappingType
      UnderlineType
      VerticalAlign
      VerticalAlignSection
      VerticalAlignTable
      VerticalMergeRevisionType
      VerticalMergeType
      VerticalPositionAlign
      VerticalPositionRelativeFrom
      WidthType

      Functions

      abstractNumUniqueNumericIdGen
      bookmarkUniqueNumericIdGen
      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
      createWrapNone
      createWrapSquare
      createWrapTight
      createWrapTopAndBottom
      dateTimeValue
      decimalNumber
      docPropertiesUniqueNumericIdGen
      encodeUtf8
      hashedId
      hexColorValue
      hpsMeasureValue
      longHexNumber
      measurementOrPercentValue
      patchDetector
      patchDocument
      percentageValue
      positiveUniversalMeasureValue
      shortHexNumber
      signedHpsMeasureValue
      signedTwipsMeasureValue
      standardizeData
      twipsMeasureValue
      uCharHexNumber
      uniqueId
      uniqueNumericIdCreator
      uniqueUuid
      universalMeasureValue
      unsignedDecimalNumber

      References

      Document → File