DOCX to PDF

Convert DOCX documents to PDF on Node.js with searchable text and native comments.

@docx-editor.dev/docx-to-pdf converts DOCX to PDF with Core pagination, font resolution, and positioned glyphs. It runs on Node.js. Browser applications send documents to a server for conversion.

The package uses the EigenPal Pro License. Production use requires a commercial agreement.

Open full-screen demo (opens in a new tab)

For a full-width view of the demo, see DOCX to PDF converter for Node.js and Next.js.

Install the converter

Install the converter and its required Core peer. Use Node.js ^20.16.0 || >=22.3.0.

npm install @docx-editor.dev/docx-to-pdf @docx-editor.dev/core

For Chinese, Japanese, or Korean text, supply suitable fonts or install @docx-editor.dev/fonts-cjk. See Add Chinese, Japanese, and Korean text.

Convert a document

The following example reads DOCX bytes, converts them, and saves the PDF:

import { readFile, writeFile } from 'node:fs/promises';
import { exportPdf } from '@docx-editor.dev/docx-to-pdf';

const source = await readFile('document.docx');
const result = await exportPdf(source, {
  displayMode: 'proposed',
  comments: true,
});

await writeFile('document.pdf', result.bytes);

Conversion preserves the source DOCX.

Choose the output

OptionDefaultEffect
displayMode'all-markup'Shows tracked insertions and deletions, with per-author colors and change bars. 'proposed' or 'original' exports text without marks at full page size.
commentstrueKeeps comments as native PDF annotations. In 'all-markup', pages also shrink beside a comment balloon pane. false omits both.
fidelityPolicy'strict'Rejects unsupported or approximate output. 'best-effort' returns output with result.diagnostics.
fontPolicy'best-effort''strict' rejects failed font sources and incomplete face coverage.

For every option, see PDF export API.

Limits

  • Conversion runs on Node.js only. Browser and Edge runtimes are unsupported.
  • Set maxPages, maxOutputBytes, and timeoutMs for your workload. See PDF export API limits.
  • CJK documents need suitable font coverage. See Configure PDF fonts.
  • The converter includes the drawing module. For rendering coverage, see DOCX fidelity.
  • To add PDF export to the editor File menu, see Export Markdown and PDF.

Next steps