How the DOCX Format Works
A DOCX file is a ZIP archive containing XML files. The main document content lives inword/document.xml, styles in word/styles.xml, images in word/media/, and relationships in _rels/ directories. This structure is defined by the Open XML specification — a complex standard covering everything from paragraph formatting to tracked changes to VBA macros.Full-fidelity DOCX-to-PDF conversion (the kind Microsoft Word itself does) requires implementing enormous portions of this specification, including font substitution, complex paragraph layout, and page geometry calculations. No pure-JavaScript library does this at 100% fidelity.
What mammoth.js Handles Well
mammoth.js is designed with a clear philosophy: extract semantic content, not visual layout. It converts:- Headings (H1-H6), Bold, italic, underline
- Bulleted and numbered lists
- Tables (basic structure)
- Hyperlinks and inline images
What It Does Not Handle
- Tracked changes: Accept or reject all changes before conversion
- Complex tables: Merged cells, nested tables may not convert accurately
- Embedded objects: Excel charts, SmartArt, and OLE objects are skipped
- Headers and footers: Page numbers and document headers are not included