feat(pdf): add a pdfmake-based PDF toolkit - #318
Open
gcutrini wants to merge 1 commit into
Open
Conversation
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.
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;pdfmakeas an optional peer.Why: react-pdf renders through react-reconciler. React 19 commits the reconciler container asynchronously, but react-pdf reads
container.document.propssynchronously right afterupdateContainer— 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.