Skip to main content
The @cle-does-things/pdfitdown package provides native Node.js bindings to the Rust PdfItDown engine via NAPI-RS.

Installation

npm install @cle-does-things/pdfitdown
# or
yarn add @cle-does-things/pdfitdown
Prebuilt binaries are available for macOS (x86_64, arm64), Linux (x86_64, arm64, musl), and Windows (x86_64, arm64).

Supported Formats

CategoryFormats
Markup.md, .html, .htm
Office.docx, .xlsx, .pptx
Images.png, .jpg, .jpeg, .webp, .tiff, .avif
Text.txt, .csv, .xml, .json, and more
Other.pdf (pass-through)

API

import { PdfItDownConverter } from '@cle-does-things/pdfitdown'

const converter = new PdfItDownConverter()

Convert a single file

converter.convertFile('input.docx', 'output.pdf', true)

Convert multiple files

converter.convertMultipleFiles(
  ['file1.docx', 'file2.pptx'],
  ['file1.pdf', 'file2.pdf'],
  true // overwrite existing
)

Convert a directory

converter.convertDirectory('./documents', true, true) // overwrite, recursive

Convert from memory (Buffer → Buffer)

import { readFileSync, writeFileSync } from 'fs'

const input = readFileSync('input.docx')
const output = converter.convertBytes(input)
writeFileSync('output.pdf', output)

Type definitions

class PdfItDownConverter {
  constructor()

  /** Convert a file on disk. */
  convertFile(inputFile: string, outputFile: string, overwrite: boolean): void

  /** Convert multiple files in one call. */
  convertMultipleFiles(inputFiles: string[], outputFiles: string[], overwrite: boolean): void

  /** Convert all supported files in a directory. */
  convertDirectory(directory: string, overwrite: boolean, recursive: boolean): void

  /** Convert a Buffer in memory and return a PDF Buffer. */
  convertBytes(input: Buffer): Buffer
}