Repository navigation
Read an annotation's dictionary const when asking where it draws - #136
Merged
Merged
Conversation
EPDFAnnot_GetDrawingRect() took the annotation's dictionary with GetMutableAnnotDict() to build the CPDF_Annot it asks. On a layer that copies the dictionary in, outside any transaction, though the call only reads: an appearance that is missing is drawn in memory, and nothing is written. The engine asks where an annotation or a widget without a stored appearance draws before it renders it. So the first render of a page left a copy of each such annotation of the file in the layer. The engine tells whether a page changed by what the layer holds of it: after a page's delete was undone and the page was rendered for the first time, it took the page for a changed one and left the redo of the delete alone. The dictionary is now read const, as a render (fpdf_view.cpp) and the flattener read it for the same drawing. Test: EPDFAnnotEmbedderTest.AskingWhereAMarkDrawsLeavesALayerAlone. It fails without the change: the layer holds one object after the call. It leaves nothing in a layer, so the list of layer-mode writers stays as it is.
bobsingor
added a commit
that referenced
this pull request
Nov 29, 2026
…/form-appearance-new-stream Main brought the inline form font fix (#134), the const read of a drawing rect (#136) and redactions through the active layer (#137). Two conflicts, each where both sides added to the same place. The ledger's own-appearance-generator paragraph keeps both additions. The list of layer-mode writers keeps both sides' tests, and EPDFFormEmbedderTest.AFieldWithoutWidgetsGetsNoDrawing, new on main, leaves 8 objects in a layer where main lists 7: one more for the new stream of its redraw.
bobsingor
added a commit
to embedpdf/embed-pdf-viewer
that referenced
this pull request
Nov 30, 2026
The release has the runtime changes merged since 7f399f838: - A redrawn form field gets a new appearance stream, where a text field, a dropdown and a list box were drawn into the one they had (embedpdf/runtime#135). An undo puts back the stream the widget named, so it brings the drawing back. The undo round trips this branch adds failed on the old pin and pass on both engines on this one. - Asking where an annotation without a stored appearance draws reads its dictionary and no longer copies it into the document's changes (embedpdf/runtime#136). - A font the form holds inline is made an object of its own before an appearance names it (embedpdf/runtime#134), and a redaction is applied at the place its mark has in a layer (embedpdf/runtime#137). - The upstream sync to 31e80351b (Nov 25 2026, embedpdf/runtime#138). The bindings generated from the release's headers don't change. runtime-src moves to the pin.
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.
Cause
EPDFAnnot_GetDrawingRect()took the annotation's dictionary withGetMutableAnnotDict()to build theCPDF_Annotit asks. The call only reads: a missing appearance is drawn in memory (MissingAppearance::kGenerateWhenDrawn) and nothing is written. But on a layer a dictionary taken for writing is copied in, and here outside any transaction, againstreads-dont-write.The engine asks where an annotation or a widget without a stored appearance draws before it renders it. So the first render of a page left a copy of each such annotation of the file in the layer.
What that broke: the engine tells whether a page changed by what the layer holds of it. A page is deleted, the delete is undone, the page is rendered for the first time, and the redo of the delete finds a page that reads as changed and leaves it. It shows when nothing drew the page before the delete in the same layer session, which is every time through the server. It is in the released runtime too.
A render (
fpdf_view.cpp) and the flattener (epdf_flatten.cpp) read the same dictionary const for the same drawing. This was the one reader that didn't.Change
EPDFAnnot_GetDrawingRect()reads the dictionary const, as those two do.reads-dont-writerule names the function and its guard.I went through every exported function of
fpdfsdk/epdf_*.cppwhose name reads (Get,Has,Is,Count,Render,Exportand the like) for aGetMutable*call in its own body. Besides this one,EPDFAnnot_ExportAppearance()andEPDFPage_ExportAnnotationsAsDocument()have one, on the copy they build and not on the source. A mutable getter behind a helper is not covered by that search.Tests
EPDFAnnotEmbedderTest.AskingWhereAMarkDrawsLeavesALayerAlone: on a layer overredact_annot.pdf, asking where the mark without an appearance draws gives its box and leaves the layer holding nothing.Checked
check-fork-tags.py --strict,check-c-api.py(604 functions).check-globals.pyon a macOS library built from this branch merged with Give every redrawn form field a new appearance stream #135.Left
fix/page-redo-after-picture-readthere, on top of the tests for Give every redrawn form field a new appearance stream #135.check-globals.py, and the saved-file checker (the change writes nothing).