Skip to content

editor: upgrade pdfkit to 0.20 and register its standard fonts - #1068

Closed
Aymericr wants to merge 1 commit into
mainfrom
cursor/deps-pdfkit-0-20-6cd4
Closed

Aymericr wants to merge 1 commit into
mainfrom
cursor/deps-pdfkit-0-20-6cd4

Conversation

@Aymericr

Copy link
Copy Markdown
Contributor

What does this PR do?

Upgrades pdfkit from ^0.19.1 to ^0.20.2 in packages/editor and adapts the floor-plan PDF export to it. Major upgrade (0.x minor), so no auto-merge.

Breaking changes (v0.20.0, v0.20.1, v0.20.2)

  • The package now has an exports map, so deep imports such as pdfkit/js/pdfkit.standalone no longer resolve. The browser entry is the default condition of pdfkit.
  • Standard fonts use pre-parsed metrics. In the browser build, each standard font must be imported from pdfkit/standard-fonts/* and registered with registerStdFonts(). Node still loads them lazily.
  • The virtual file system (pdfkit/virtual-fs) is removed in favour of registerFile(path, Uint8Array). Buffer is no longer used internally.
  • Named exports are added (PDFDocument, LineWrapper, registerFile). AcroForm options are restricted to the documented mappings, annotation option keys are no longer uppercased automatically, and addNamedEmbeddedFile throws when no ref is given.
  • New experimental toBytes/toBlob helpers are available in pdfkit/output.

Code changes

  • createFloorplanPdfDocument imports pdfkit instead of pdfkit/js/pdfkit.standalone, and registers the four standard faces the export falls back to (Helvetica, Helvetica-Bold, Courier, Courier-Bold). This is required: the PDFDocument constructor sets Helvetica, so the browser build throws Standard font "Helvetica" is not registered on new PDFDocument() without it. The Node build has no registerStdFonts and loads its own metrics, so the call is optional-chained.
  • Adds pdfkit-standard-fonts.d.ts, because 0.20 ships the standard-fonts/* entry points untyped and @types/pdfkit 0.17.6 (the latest) predates them.

How to test

  1. bun install && bun run ci
  2. In bun dev, export a floor plan to PDF, then block the pdf-fonts/*.ttf requests and export again. The second export exercises the standard-font fallback.

Screenshots / screen recording

Not added yet.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

Local results: check, skills:validate, check-types and build pass, with only the local-only test failures that main also has. A script against pdfkit 0.20's browser build confirmed two things: an unregistered new PDFDocument() throws, and after registering the four faces it renders all of them to a valid PDF. The full browser export flow has not been clicked through.

Open in Web Open in Cursor 

0.20 no longer exposes js/pdfkit.standalone and its browser build ships no
standard-font metrics until they are registered, while the PDFDocument
constructor already sets Helvetica. Load the package entry and register the
four faces the floor-plan export falls back to.
@Aymericr

Copy link
Copy Markdown
Contributor Author

Landed in #1071 (dc65ba0), which combined the nine major upgrades with one lockfile. Closing as superseded. #1061 stays open.

@Aymericr Aymericr closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants