graft: fix invisible text appearing after strip_invisible_text #1448
+81
−5
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.
strip_invisible_text resets the text render mode on each
BT
(begin text) command. However the text state is not actually reset for each text element, only for each page.The pdf reference says:
With the current implementation, a text object is only deleted if it contains a
3 Tr
command (setting the text rendering mode to invalid). However the rendering mode may be set once and then not changed for multiple text objects or set outside of a text object.In that case only the first text object (which contains the
3 Tr
-command) is removed. This not only leaves the other text objects in the pdf, but also makes them visible, since the text object that contained the3 Tr
-command is removed.This PR updates
strip_invisible_text
to not reset the rendering mode for each object and to keep track of the rendering mode when the graphic state is pushed/popped.