openpdf-renderer: support Tr text rendering mode (fixes invisible OCR text layers rendering as visible) - #1603
Open
andreasrosdalw wants to merge 2 commits into
Conversation
Previously the renderer always filled text regardless of the active PDF §9.3.3 text rendering mode, so invisible text (Tr 3), which scanned-PDF / OCR pipelines rely on to lay a searchable text layer over a page-image XObject, would incorrectly render as visible glyphs on top of the image. Add Tr parsing plus fill/stroke/invisible handling (modes 4-7, which also add glyphs to the clip path, degrade to their 0-2 fill/stroke behavior since text clipping isn't implemented). Update the README operator tables and docs to match.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 7 |
| Duplication | 6 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Consolidated into LibrePDF#1607 along with the README updates for LibrePDF#1604, LibrePDF#1605, and LibrePDF#1606, so these four independent PRs (all based on master) don't each carry their own overlapping README.md diff and risk merge conflicts with each other depending on merge order.
andreasrosdalw
added a commit
to andreasrosdalw/OpenPDF
that referenced
this pull request
Jul 28, 2026
Consolidated into LibrePDF#1607 along with the README updates for LibrePDF#1603, LibrePDF#1605, and LibrePDF#1606, so these four independent PRs (all based on master) don't each carry their own overlapping README.md diff and risk merge conflicts with each other depending on merge order.
andreasrosdalw
added a commit
to andreasrosdalw/OpenPDF
that referenced
this pull request
Jul 28, 2026
Consolidated into LibrePDF#1607 along with the README updates for LibrePDF#1603, LibrePDF#1604, and LibrePDF#1606, so these four independent PRs (all based on master) don't each carry their own overlapping README.md diff and risk merge conflicts with each other depending on merge order.
andreasrosdalw
added a commit
to andreasrosdalw/OpenPDF
that referenced
this pull request
Jul 28, 2026
Consolidated into LibrePDF#1607 along with the README updates for LibrePDF#1603, LibrePDF#1604, and LibrePDF#1605, so these four independent PRs (all based on master) don't each carry their own overlapping README.md diff and risk merge conflicts with each other depending on merge order.
|
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.



Summary
OpenPdfCorePageRenderer(theopenpdf-core-backed Java2D rasterizer used byOpenPdfCoreRenderer) never parsed theTroperator, so text was always filled regardless of the active PDF §9.3.3 text rendering mode.Tr 3) searchable text layer directly on top of a page-image XObject. Without honoringTr, that invisible text was incorrectly rendered as visible black glyphs on top of the scanned image.Trhandling: mode 0 fill (previous/default behavior), mode 1 stroke (viaFont.createGlyphVector+BasicStrokeusing the current stroke color/width/dash/join), mode 2 fill+stroke, and modes 3/7 invisible (skip painting entirely). Modes 4-6 (which additionally add glyphs to the clipping path) fall back to their 0-2 fill/stroke behavior — text clipping isn't implemented, called out explicitly in code and README.openpdf-renderer/README.md's operator-support tables and text-rendering section to documentTrsupport and the clip-mode caveat.