Repository navigation
Conversation
…change iOS Markup stores a private copy of a page's markup (/AAPL:PPK and /AAPL:PPKHash on the page, /AAPL:AKExtras on each annotation) and draws from it. After PdfCraft added a signature to a page signed in Markup, iOS showed the Markup signature twice: in its own place and over the new one. Removing the copy whenever set_annots changes the list makes Apple draw every annotation from its appearance, as other viewers do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ahmadmuj
reviewed
Oct 16, 2026
ahmadmuj
left a comment
There was a problem hiding this comment.
Could the removal record a fidelity warning, given the reported loss of live ink editing? Adding one note removes the Apple data across the page, but leaves repair_log empty.
There is also a low-level rejection case: set_style on an inline locked stamp returns "the comment is locked" after removing the private keys. Please defer removal until validation succeeds. The engine currently protects failed user edits by discarding its copy.
Synthetic save/reopen checks preserve exact appearance bytes, resources, flags, and stamp pixels across eight variants. The committed regression could include an appearance stream too; its stamp currently has no /AP. I could not test iOS.
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.
What this changes
A page signed with iOS Markup carries Apple's private copy of its markup:
/AAPL:PPKand/AAPL:PPKHashon the page, and/AAPL:AKExtrason each Markup annotation. After PdfCraft adds a signature to such a page, iOS (seen on iOS 26.6.1) displays the Markup signature twice: in its own place and over the signature PdfCraft added. Every other viewer we tried, PdfCraft included, renders the file correctly. The saved PDF is valid; Apple is drawing from its now-stale private copy.set_annotsis the single place where a page's annotation list changes (add, delete, reply, links, inline-dict promotion). It now removes those three keys from the page and from the page's annotations first, so Apple falls back to drawing every annotation from its appearance stream, as other viewers do. The Markup annotation itself, its/APand its flags are kept, and Apple keys are only touched when present (no extra objects in an incremental save otherwise).How you verified it
On a real document (signed with iOS Markup, then signed in PdfCraft 0.8.0), opened on an iPhone:
/AAPL:PPK+/AAPL:PPKHashremoved/AAPL:AKExtrasremoved (what this PR does)So the page-level keys alone are not enough;
/AAPL:AKExtrashas to go too.cargo fmt --check(-p pdfcraft-annot)-D warnings:cargo clippy -p pdfcraft-annot --all-targets -- -D warningscargo test -p pdfcraft-annot(43 passed)cargo xtask layers/assets: not applicable, no crate boundary or asset touchedTests. New unit test
adding_to_an_apple_markup_page_drops_apples_stale_copy(synthetic fixture shaped like an iOS Markup page). Seen failing with thedrop_apple_markupcall reverted, passing with it. End-to-end: apdfcraft-cli runscript (doc_open,fill_sign_addimage signature,doc_save) on the real file leaves noAAPL:keys behind, and both stamps survive.Never-crash
unwrap/expect/panic!/unreachable!/todo!outside testsunsafeProvenance
Security
Parity and reach
parity/not updated: interop fix, not a featurefill_sign_add/comment_add/stamp_customtoolsAnything a reviewer should look at first
/Annotsalready holds; keeping them is what produces the wrong rendering. The cost is that iOS can no longer re-edit the Markup strokes as live ink; they stay as their normal appearance. The iOS stamp in the report is/F 644(Locked + LockedContents) anyway. If you'd rather record the drop somewhere (a warning on the edit result?), I'm happy to add it.set_annots). Moving or restyling an existing Markup annotation leaves the stale copy, which could show the old position on iOS. I kept the change minimal rather than guess at that case without a repro.cargo test -p pdfcraft-enginewas not run locally (CI runs the workspace).🤖 Generated with Claude Code