4.9: glyphs missing from rendered PDF when multiple documents are rendered in one process (regression from 4.3)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- backend
Research direction
Start by reproducing with two renderToBuffer calls in one Node process, with the second document using bold/semibold glyphs the first did not, and compare against a fresh-process render. The payload points at font and subset state in @react-pdf/font and the switch to upstream pdfkit, plus the ToUnicode CMap output in the PDF. Done means sequential renders produce the same glyphs and CMap as isolated renders, with no empty bfrange destinations.
Written by the indexing model from the issue text.
Description
Describe the bug
Since upgrading from @react-pdf/renderer 4.3.2 to 4.9.0, glyphs occasionally disappear from the rendered page when several documents are rendered in the same Node process. The failure depends on render order: the same document rendered alone in a fresh process is correct.
Observed: a short bold/semibold label WO (Inter, ~7pt, registered via Font.register with local TTFs for weights 400/500/600/700) renders as O. The W is missing visually, not just from the text layer. The same string in regular weight on the same page renders fine. In the same output, the ToUnicode CMap sometimes contains an empty destination (<>) inside a bfrange array for a glyph that was used in an earlier render, so copy/search also lose characters (e.g. umlauts).
4.3.2 renders the identical sequence of documents correctly, pixel for pixel.
To Reproduce
- Register Inter (multiple weights) with
Font.register. - In one Node process, call
renderToBufferon several different documents in sequence that share the font but use different character sets in bold/semibold runs. - Rasterize the later documents: some glyphs in bold/semibold runs are missing. Rendering the affected document first, or in a fresh process, shows them correctly.
Expected behavior
Each renderToBuffer call is independent of previous renders; all glyphs are drawn.
Environment
@react-pdf/renderer4.9.0 (@react-pdf/layout5.2.0,@react-pdf/textkit7.0.1,@react-pdf/render4.7.0,@react-pdf/font4.1.2,pdfkit0.20.1)- Node 24.11 / Node 22 (server-side rendering in a long-lived Next.js server)
- Not reproducible on 4.3.2 (
@react-pdf/pdfkit4.1.0, textkit 6.1.0)
Possibly related to the switch from @react-pdf/pdfkit to upstream pdfkit: font/subset state appears to carry over between documents.
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diegomura/react-pdf
-
@react-pdf/font: published types import fontkit, but @types/fontkit is only a devDependencyPossibly taken @iliev-blnk claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Unable to set flexShrink to 0Possibly taken @adarshsm claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
@react-pdf/hyphenate: import-only exports map throws ERR_PACKAGE_PATH_NOT_EXPORTED in require-condition resolvers (every tsx script loading renderer >= 4.7 crashes)Possibly taken @cruzdanilo claimed this 39 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
diegomura/react-pdf#3551 · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
diegomura/react-pdf#3606 · 3 reactions ·
Maintainers usually reply within 1 day
All issues in diegomura/react-pdf
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
kunchenguid/gh-axi#247 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
lidge-jun/opencodex#8101 · 2 comments ·
Maintainers usually reply within 1 day
-
effort:S P3 refactor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nightscout/nocturne#3243 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JuliusBrussee/caveman#1449 ·
Maintainers usually reply within 1 day