Convert Word to PDF in Node.js

Searchable PDF with embedded fonts, comments, and tracked changes.

Use it in your application

Available as a TypeScript package for Node.js.

View on npm

Installs the converter and its required core dependency. Production use requires a Pro license.

Output
PDF file
Runtime
Node.js 20.16+ within 20.x, or 22.3+
License
EigenPal Pro

What the PDF includes

Convert DOCX files to PDF on your Node.js server. Use the same fonts and layout settings as the editor to keep page breaks consistent.

Searchable text and embedded fonts

Search, select, and copy text. The PDF embeds the fonts used for layout.

Configure fonts

Diagnostics for unsupported content

Strict mode rejects unsupported or approximate output. Best-effort mode returns available output with diagnostics.

Review diagnostics

Why does PDF conversion use the editor layout engine?

The converter and editor share a layout engine. Use the same fonts and layout settings to keep page breaks consistent between the preview and PDF.

Add PDF export to your application

Convert on the server. The client sends DOCX bytes and receives a PDF.

  1. 01

    Configure server fonts

    Supply the fonts used in your documents. Disable system fonts to keep font selection consistent across servers.

    Configure PDF fonts
  2. 02

    Return a PDF response

    Convert the request body in a Node.js route. Set limits for page count, output size, and conversion time.

    Integrate PDF conversion
  3. 03

    Export PDF and Markdown together

    Open the document once and export both formats from the same layout.

    Compare PDF and Markdown

Convert DOCX to PDF in TypeScript

Pass DOCX bytes to exportPdf and save result.bytes. Use displayMode and comments to configure review content.

Check result.diagnostics for output limitations. Strict mode rejects unsupported or approximate output.

Read the integration guide
convert.mtsNode.js / TypeScript
import { readFile, writeFile } from 'node:fs/promises';
import { exportPdf } from '@docx-editor.dev/docx-to-pdf';

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

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

console.log(result.pageCount, result.diagnostics);

Common DOCX to PDF use cases

Contracts and legal

Share the final version

Export a contract with or without markup. Keep comments as annotations.

Document generation

Generate reports and letters

Fill a Word template with the editing API, then convert it to PDF in the same process.

Archives and records

Store a PDF per version

Save a PDF with each document version. Record package versions and font settings to reproduce it.

Common questions

How do I convert DOCX to PDF in Node.js?

Install @docx-editor.dev/docx-to-pdf and @docx-editor.dev/core. Pass the file bytes to exportPdf and write result.bytes to a .pdf file.

Can I convert DOCX to PDF without LibreOffice?

Yes. The converter runs inside your Node.js process with WebAssembly and packaged fonts. You do not run Word, a headless browser, or a separate conversion service.

Does it run in serverless functions?

Yes. Use a Node.js runtime and bundle the converter's WebAssembly and font assets. Configure memory and timeouts for your largest documents. Edge runtimes are not supported.

Can I convert DOCX to PDF in a Next.js route?

Yes. Use the Node.js runtime and add the converter packages to serverExternalPackages. Edge and browser runtimes are not supported.

Will the PDF match Microsoft Word exactly?

Not always. Missing fonts and unsupported content, such as charts, can affect conversion. Compare representative files against Word page by page, and check result.diagnostics.

Does the converter substitute fonts silently?

No. Inspect result.fontResolution for font substitutions. Strict PDF fidelity mode rejects generic substitutions that can change page breaks.

Are tables and page breaks preserved?

The converter supports tables and page breaks. Unsupported content, such as rotated table-cell text, causes strict conversion to fail or produces diagnostics in best-effort mode.

Can I fill a DOCX template and then convert it to PDF?

Yes. Fill the template with the document editing API, then pass the saved bytes to exportPdf in the same process.

Can I convert a legacy .doc file to PDF?

No. Save it as .docx first. The converter accepts only .docx files.

How much does the PDF converter cost?

Evaluation is free. Production use requires a Pro license. See pricing.

Can I export PDF from the editor's File menu?

Yes. The editor posts the document to your conversion route. For more information, see Export Markdown and PDF.

Convert your first document to PDF

Try docx-to-pdf.dev or add the package to your Node.js server.

Need text for agents or search? Convert Word to Markdown.