Enable Incremental Saving of PDFs Using JavaScript
When persisting changes to an open document, two main strategies are available: incremental saving and full saving.
Incremental saving consists of appending new changes to the end of a document while keeping the previous versions of it intact, which is useful when working with digitally signed documents, as digital signatures are invalidated if the integrity of the signed content is compromised.
Full saving, on the other hand, rewrites the entire document instead of appending changes at the end of it. This prevents the document file size from growing on every revision, but it’s slower than incremental saving.
PSPDFKit for Web uses full saving by default, except for with digitally signed documents, which use incremental saving by default (if the Digital Signatures component is present in the license). If you wish to use incremental saving instead, you have to set the incremental
flag to true
when calling Instance#exportPDF()
:
instance.exportPDF({
incremental: true
});
If the incremental
and the flatten
flags are both set to true
when passed to instance#exportPDF()
, the call will throw an error, as flattening is a destructive operation that removes the annotations from the exported document. In that case, incremental saving won’t be possible.