Skip to content

feat(pdf): add a pdfmake-based PDF toolkit - #318

Open
gcutrini wants to merge 1 commit into
mainfrom
feature/pdf-toolkit
Open

feat(pdf): add a pdfmake-based PDF toolkit#318
gcutrini wants to merge 1 commit into
mainfrom
feature/pdf-toolkit

Conversation

@gcutrini

Copy link
Copy Markdown
Contributor

Ref: https://app.clickup.com/t/86bbf0d90

Ports the pdfmake PDF toolkit (src/utils/pdf) to the 5.x line. Same surface as the 4.x PR: createDocument, resolveFont, imageDataUrl, downloadBlob, field, badge; pdfmake as an optional peer.

Why: react-pdf renders through react-reconciler. React 19 commits the reconciler container asynchronously, but react-pdf reads container.document.props synchronously right after updateContainer — so under React 19 it reads null and throws (Cannot read properties of null (reading 'props'), upstream diegomura/react-pdf#3223); under React 17/18 the commit was synchronous and never raced. Our stack spans React 17/18 (legacy widgets) and React 19 (the Next event site), so PDF generation broke on React 19. pdfmake has no reconciler, so it sidesteps this entirely.

Add src/utils/pdf: a React-agnostic PDF toolkit built on pdfmake. Pure
templates (data, { font }) => docDefinition run through createDocument,
which resolves the font, builds the document, and returns download/open/
print/getBlob/getBase64. Ships no font or image: resolveFont and
imageDataUrl fetch + base64 a consumer-provided brand font/logo (pdfmake's
browser build can't load either by URL) and fall back to Helvetica.
field and badge are shared docDefinition node builders; downloadBlob
saves via a light-DOM anchor so it works from inside a shadow root.

pdfmake is an optional peer: the toolkit never imports it, the consumer
injects its own instance, so there is one VFS and one singleton owner.
@gcutrini
gcutrini requested a review from smarcet August 16, 2026 18:28
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 997b57f1-5558-49ca-82db-fa127fc6c14f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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