Skip to content

Comments

Incremental Update Change Automatic Registration#1

Open
adnsistemas wants to merge 248 commits intoremdra:masterfrom
adnsistemas:master
Open

Incremental Update Change Automatic Registration#1
adnsistemas wants to merge 248 commits intoremdra:masterfrom
adnsistemas:master

Conversation

@adnsistemas
Copy link

What?

It automates the incremental update object change registration, making incremental update as easy as adding a parameter on document load.

Why?

It's very error prone to be required to manually register every ref that has to be included in an incremental update.

How?

The snapshot is preserved at the pdf context, and every PDFObject registers when it changes, with the context. If the PDF has an original file (was loaded) then this changes get registered in the snapshot taken on document load.

Testing?

Added a couple of tests. Run all the tests, and integration tests for Node, Deno and Browser.

New Dependencies?

No

Screenshots

No visual changes.

Suggested Reading?

I already know the PDF standard pretty well.. no need to read it again.

Anything Else?

I will add a Pull Request to the orinal PDF-LIB.

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 September 1, 2025 14:52
…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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.