npm / pdfkit
pdfkit
What changed in pdfkit 0.18 to 0.20, from its official release notes, upgrade guides and advisories. Also covers @types/pdfkit. Sources checked 2026-11-30.
8 breaking1 security14 new APIs and options21 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpdfkit 0.2022 changes
Breaking changes 6
In Node, importing pdfkit now resolves to a Node ESM build with the real file system, native zlib, Node streams, and self-registering standard fonts instead of the browser bundle.
AcroForm options are restricted to documented mappings and explicit escape hatches.
Throws when no ref is given instead of writing an unparseable undefined token into the /EmbeddedFiles name tree.
Annotation option keys are no longer automatically uppercased.
Browser applications must import each standard font they use and register it with registerStdFonts(); Node continues to load font metrics lazily.
The virtual file system was removed. Register in-memory data with registerFile, pass binary data directly to registerFont, image, or file, or pass data URLs to image and file.
Security 1
Strings inside name trees are now encrypted.
New APIs and options 7
doc.font() now accepts already-parsed fontkit Font instances.
LineWrapper is now available as a named export from the main Node and browser entry points.
PDFDocument is now available as a named export from the main Node and browser entry points; the default export is preserved.
Register in-memory files globally in Node and browsers, optionally with birthtime and ctime metadata; passing undefined as data unregisters the path.
registerFont now accepts already-parsed fontkit Font instances.
An experimental helper under pdfkit/output returns a Promise resolving to a Blob containing the document output.
An experimental helper under pdfkit/output returns a Promise resolving to a contiguous Uint8Array containing the document output.
Fixes and other changes 8
Calling doc.file() twice with the same in-memory attachment under one name no longer throws when deduplication checks dates that are absent for sources not read from disk.
doc.text() no longer throws
unsupported number: NaNwhen lineBreak is false and underline, strike, link or goTo is used.The mapping now resolves to a single file under all conditions, preventing bundlers and file tracers from packing ESM font metrics that cause runtime module-not-found errors.
Fixes invalid JavaScript emitted by date text field formatting, which prevented the format from being applied.
doc.annotate() and its convenience methods no longer mutate the options passed to them.
Fixes repeated indentation across paragraphs and page breaks, and keeps the indent applied across continued text.
Font options are now persisted when adding a new page.
Fixes skipped holes in sparse arrays that shifted every later entry down one.
pdfkit 0.1911 changes
Breaking changes 2
The minimum supported browsers are now Firefox 115 and iOS/Safari 16.
The minimum supported Node.js version is now 20+.
New APIs and options 4
Adds an opacity option to control image transparency.
Adds bbox support for PDF/UA compliance.
Adds placement support for PDF/UA compliance.
Adds borderRadius as a number for all corners or a per-corner array in CSS order.
Fixes and other changes 5
Fixes RGB JPEGs being embedded as DeviceGray, correcting how those images are handled.
Fixes PDF Name escaping for spot colors with spaces.
Fixes accessibility scope in TH elements.
Fixes PDF corruption when standard and embedded fonts share a postscript name.
Fixes handling of text input when x is null.
pdfkit 0.1811 changes
New APIs and options 3
Outlines can now jump to specific page positions with a custom zoom level.
Adds an option to control how pages are displayed in PDF viewers.
Adds an option for specifying custom page units, using PDF 1.6.
Fixes and other changes 8
Fixes indentation when indentAllLines is true and a new page is created.
Fixes incorrect rendering of interlaced PNG images with indexed transparency.
Adds robust handling for null byte padding in JPEG images.
Fixes accessibility issues with links in generated PDFs.
Adding outlines now preserves the existing PageMode instead of overwriting it.
Fixes parsing of SVG arc flags when they have no separators.
Fixes a table accessibility issue involving the CS/cs operator.
Fixes garbled text copying in Chrome and Edge for PDFs with more than 256 unique characters.