Repository navigation
Conversation
FreeText annotations were written without an /AP entry, so viewers that do not synthesize one (such as Chrome/PDFium) showed the box but not the text. Build a normal appearance stream (/AP /N) from the annotation's background, border, color, size and bold/italic settings, and store it as an indirect object when the annotation is added. Fixes py-pdf#2372
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4358 +/- ##
=======================================
Coverage 98.81% 98.81%
=======================================
Files 59 59
Lines 12139 12174 +35
Branches 2310 2317 +7
=======================================
+ Hits 11995 12030 +35
Misses 70 70
Partials 74 74 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Fixes #2372.
FreeText.__init__set/DA,/DS,/Cand/BSbut never built an appearancestream (
/AP). Viewers that don't synthesize one — notably PDFium, which Chromeuses — draw the annotation box but not the text.
This adds a
_free_text_appearance_stream()helper that builds a normal appearancestream (
/AP/N) from the annotation's background, border, colour, size andbold/italic settings, and
add_annotationnow stores it as an indirect object (astream can't sit directly inside the annotation dict).
Test
tests/test_annotations.py::test_free_text__appearance_streamfails on theunpatched code with
KeyError: '/AP'and passes after;test_annotations.pyis52/52. Rendered with PDFium the text now shows.
Known limitations (happy to address if preferred):
font=argument is drawn as standard Helvetica; text is not wrapped;?.Prepared with help from an AI coding assistant; I reviewed and tested it locally.