npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

docx-to-pdf-lite

v1.0.0

Published

DOCX to PDF conversion for Node.js with Microsoft Word, LibreOffice, and docx-preview/PlutoPrint engines.

Readme

docx-to-pdf-lite

Convert .docx files to .pdf from Node.js.

This package gives the best results when Microsoft Word is installed locally. On Windows, the default auto engine uses Word's own PDF export first, which is the closest result to Word Print Preview / Save as PDF.

If Microsoft Word is not available, it falls back to LibreOffice when installed. If neither Word nor LibreOffice is available, it uses a pure Node fallback based on docx-preview and plutoprint.

Installation

npm install docx-to-pdf-lite

Basic Usage

const { convertDocxToPdf } = require('docx-to-pdf-lite');

await convertDocxToPdf('input.docx', 'output.pdf');

API

convertDocxToPdf(inputPath, outputPath, options?)

Converts a .docx file to a .pdf file.

Parameters

  • inputPath (string): Path to the source .docx file.
  • outputPath (string): Path where the generated .pdf file should be saved.
  • options (object, optional): Conversion options.

Options

{
  engine: 'auto', // 'auto', 'msword', 'libreoffice', or 'preview'
  format: 'A4', // 'A4' or 'Letter'; used by the preview engine
  margin: null, // optional preview-engine margin object
  timeout: 120000,
  libreOfficePath: 'C:\\Program Files\\LibreOffice\\program\\soffice.exe'
}

Engines

  • auto: Default. Tries Microsoft Word on Windows, then LibreOffice, then the preview fallback.
  • msword: Uses Microsoft Word COM automation. This gives the most accurate output, but only works on Windows with Microsoft Word installed locally.
  • libreoffice: Uses local LibreOffice / soffice headless conversion. This is the best open-source fallback when Word is unavailable.
  • preview: Uses docx-preview and plutoprint. This is the lightest fallback, but it is not pixel-perfect for complex Word documents.

Returns

Promise<void>

Best Fidelity

For perfect or near-perfect rendering, use:

await convertDocxToPdf('input.docx', 'output.pdf', {
  engine: 'msword'
});

This requires Microsoft Word to be installed on the same Windows machine running Node.js.

LibreOffice Fallback

LibreOffice is used automatically by engine: 'auto' when Word is unavailable.

You can force it:

await convertDocxToPdf('input.docx', 'output.pdf', {
  engine: 'libreoffice'
});

If LibreOffice is not on PATH, pass the executable path:

await convertDocxToPdf('input.docx', 'output.pdf', {
  engine: 'libreoffice',
  libreOfficePath: 'C:\\Program Files\\LibreOffice\\program\\soffice.exe'
});

Preview Fallback

The preview engine does not require Microsoft Word or LibreOffice:

await convertDocxToPdf('input.docx', 'output.pdf', {
  engine: 'preview'
});

This path is cross-platform, but complex spacing, indentation, fonts, headers, footers, and page breaks may differ from Microsoft Word.

Limitations

  • Perfect Word-like output requires Microsoft Word installed locally on Windows.
  • LibreOffice output is usually good, but can still differ from Microsoft Word for complex documents.
  • The preview engine is a fallback only and is not intended to be pixel-perfect.
  • plutoprint includes prebuilt PlutoBook binaries on Windows and Linux x86_64. macOS may require PlutoBook to be installed separately with Homebrew.
  • Password-protected or corrupted DOCX files are not supported.