Skip to content

Conversation

@adnsistemas
Copy link

What?

Remdra changes implements incremental update. Over that I added the automatic change tracking, so you only has to add a parameter on PDF load, for it to be saved with incremental updates. On save, you can force rewrite, if open for incremental update.

Why?

Incremental updates are a requirement for electronic signatures, otherwise, only the last signature remains valid, and all the previous ones are invalidated on PDF rewrite.

How?

Remdra changes implements the concept of 'snapshot' wich tracks new PDF objects and allows you to register objects that has changed, to be included in the incremental update to add at the end of the original PDF file.
Over that I added the preservation of the snapshot at PDF context and the autochangeregistration of PDF Objects, when they change, with context.

Testing?

Added test. Run all tests except ios/android

New Dependencies?

No.

Screenshots

No visual changes.

Suggested Reading?

I've read PDF standard several times..

Anything Else?

Nothing else.

Checklist

  • [x ] I read CONTRIBUTING.md.
  • [x ] I read MAINTAINERSHIP.md#pull-requests.
  • [x ] I added/updated unit tests for my changes.
  • [x ] I added/updated integration tests for my changes.
  • [x ] I ran the integration tests.
  • [x ] I tested my changes in Node, Deno, and the browser.
  • I viewed documents produced with my changes in Adobe Acrobat, Foxit Reader, Firefox, and Chrome.
  • [x ] I added/updated doc comments for any new/modified public APIs.
  • [x ] My changes work for both new and existing PDF files.
  • [x ] I ran the linter on my changes.

adnsistemas and others added 30 commits July 19, 2025 11:00
…f deletions. Deletion of pages objects on page removal. Snapshots ref deletion registration
…entify changed objects in incremental updates. This is requiered for electronic/digital signature validation
…e and incremental generation. Parameter adding for incremental update saving, to force useObjectStreams preference
- Add commit() method to PDFDocument enabling chained incremental updates
- Fix font duplication: change 'modified' flag to 'alreadyEmbedded' in PDFFont
- Use PDFWriter instead of PDFStreamWriter for incremental saves
- Add comprehensive tests for commit() functionality (17 test cases)
- Add commit() method to PDFDocument enabling chained incremental updates
- Fix font duplication: change 'modified' flag to 'alreadyEmbedded' in PDFFont
- Use PDFWriter instead of PDFStreamWriter for incremental saves
- Add comprehensive tests for commit() functionality (17 test cases)
Previously, inline objects (arrays/dicts embedded directly in other
objects, not registered as indirect objects) would not be tracked
for incremental saves. This caused changes to inline arrays like
MediaBox to be lost.

The fix enhances PDFContext.registerObjectChange() to:
1. First check if the object is directly registered (indirect object)
2. If not, search through all indirect objects to find which one
   contains the inline object, and mark that parent for save

Also fixed lint-staged config that had broken shell commands.

Added test: 'tracks inline array modifications for incremental saves'

All 673 tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.