The public API, option types and Node.js >=22.13.0 requirement are unchanged from 4.2.1. The full list of changes is in the CHANGELOG.
Highlights
- CCITT, JBIG2 and JPEG 2000 images render again. They came out blank with no error, because pdf.js never received its
wasmUrl(#278). A hang when several conversions ran at the same time on the main thread is also fixed (#288). - Fonts and CJK text now render correctly whatever the working directory (
npx, pnpm, a process started outside the project root). pdf.js assets now come from the installedpdfjs-distpackage instead of from./node_modules. pdfjs-dist6.4.299 and@napi-rs/canvas1.0.13. Rendering is faster (the full fixture set took 2.4 s, down from 4.2 s, and image-heavy pages are up to 3× faster). Decoding very large images is slower (54 s for a 529-million-pixel image), and PNG bytes can differ slightly.- New: the
PDF_TO_PNG_PASSWORDenvironment variable for the CLI, thePDF_TO_PNG_WASM_MISSINGandPDF_TO_PNG_DISABLE_FONT_FACE_IGNOREDprocess warnings, andSharedArrayBufferinput from other realms. - Hardening: input validation is stricter, a failed write no longer leaves a truncated PNG, the duplicate-name check now folds Unicode, and 2 GiB+ inputs are now read in chunks.
Check before upgrading
These changes can make a call that worked on 4.2.1 fail or produce different output:
- The CLI rejects more than one positional argument, such as a
*.pdfglob orfile.pdf --silent true. - A string input longer than 4096 characters is rejected before it reaches the filesystem.
- Output names that differ only by Unicode case or normalization, such as
straße.pngandSTRASSE.png, are rejected as duplicates on every filesystem. returnMetadataOnlyandreturnPageContent: falsereject a page with a side longer than 1,000,000 px.- Width and height can grow by one pixel at some scales (2974 × 3849 becomes 2975 × 3850).
disableFontFace: falseis ignored, and the library emits a warning.- Images in these formats now decode, so memory and time per page can go up: about 8 bytes per declared pixel per rendering thread. Set memory and time limits for untrusted PDFs.
- A declared image of about 537 million pixels or more is now silently left out of the page, where it used to make the conversion fail.