Convert DOCX 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.
Installs the converter and its required core dependency. Production use requires a Pro license.
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.
Comments and tracked changes
displayMode to 'proposed', 'original', or 'all-markup' to control how tracked changes appear.Diagnostics for unsupported content
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.
- 01
Configure server fonts
Supply the fonts used in your documents. Disable system fonts to keep font selection consistent across servers.
Configure PDF fonts - 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 - 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.
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
Document generation
Generate reports and letters
Archives and records
Store a PDF per version
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 a desktop word processor, 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 desktop word processors exactly?
Not always. Missing fonts and unsupported content, such as charts, can affect conversion. Compare representative files against your target word processor 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 DOCX to Markdown.