iOS: XFDF does not persist deletion when all annotations are removed (last annotation cannot be deleted)

Product: PDFTron.iOS and PDFTron.iOS.Tools

Product Version: 11.3.0

Please give a brief summary of your issue:
We are facing a consistent issue in PDFTron iOS where annotation deletions are not persisted when all annotations are removed from a document.

Please describe your issue and provide steps to reproduce it:
Observed behavior:

  1. If a PDF contains N annotations:

    • Deleting N-1 annotations works correctly

    • The remaining annotations are saved properly via XFDF

  2. However:

    • The last remaining annotation cannot be deleted

    • If all annotations are erased at once, none of the deletions are persisted

    • On reopening the document, all annotations reappear

  3. This behavior is not related to a specific annotation type:

    • It occurs for ink, shapes, comments, etc.

    • Any single annotation can act as the “last one”

    • At least one annotation must remain for deletions to persist

Expected Behavior

  • Deleting all annotations should result in:

    • XFDF correctly representing an empty annotation state

    • Reopening the document with zero annotations

Actual Behavior

  • When annotation count reaches zero:

    • PDFDoc.FDFExtract(e_annots_only).SaveAsXFDF() does not reflect deletions

    • The last annotation appears to be deleted visually but is not persisted

    • XFDF export does not represent the “all annotations deleted” state

Reproduction Steps

  1. Open a PDF with multiple annotations

  2. Erase all annotations

  3. Save annotations using XFDF export

  4. Reload document / reapply XFDF

Result:
All annotations reappear

Control case:
If at least one annotation remains → deletions persist correctly

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It seems like you’re encountering an issue where the last annotation in a PDF document isn’t being deleted when using XFDF with Apryse’s (formerly PDFTron) iOS SDK. This is likely due to the way XFDF handles deletions, especially when all annotations are removed.

Some things you can try:

  • Ensure that you are using the MergeXFDF API correctly with the command file format, which allows deletions to be processed.

  • Check if you are using the Force option with MergeXFDF to handle unnamed annotations, as this may affect deletion persistence.

  • Verify that the XFDF export and import operations are correctly implemented to reflect the changes in the annotation state.

  • Consider exporting and re-importing the XFDF after each deletion operation to ensure that the document state is updated properly.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

Thank you for reaching out through our Forum. If you could provide a minimal runnable sample project submitted through a support ticket here: Submit a ticket : Apryse
I’ll be able to further assist you. I look forward to your response.