modern-pdf-lib / saveIncremental
Function: saveIncremental()
saveIncremental(
originalBytes,registry,structure,changedObjects,options?):IncrementalSaveResult
Defined in: src/core/incrementalWriter.ts:245
Perform an incremental save of a PDF document.
Takes the original file bytes and a registry of objects (some new, some modified), and appends only the changed objects plus a new xref section and trailer.
The resulting bytes form a valid PDF file that preserves the original content byte-for-byte and appends the modifications.
Parameters
originalBytes
Uint8Array
The original PDF file bytes (unmodified).
registry
The object registry containing all objects (original + new/modified).
structure
Document structure references (catalog, info, pages).
changedObjects
Set<number>
Set of object numbers that are new or modified.
options?
Optional save options (compression, etc.).
Returns
The complete incremental save result.
Example
const result = saveIncremental(originalBytes, registry, structure, changedObjects);
await writeFile('output.pdf', result.bytes);