Incremental PDF Saving in Java

By default, PSPDFKit saves to files incrementally. This is a feature of PDFs and means that when saving, the initial content of the original document isn’t altered, and all changes are appended to the file. This can result in a significantly faster save when working with a large file, as changes are typically quite small.

However, you should bear in mind that since the changes are always appended, the file will constantly increase in size with every save, regardless of the changes being made. Since this is sometimes undesirable, you can specify that the PDF should be completely rewritten upon saving.

Here’s an example of saving incrementally: DocumentSaveOptions.Builder().incrementalSave(true).build());

Here’s how to rewrite the PDF when saving: DocumentSaveOptions.Builder().incrementalSave(false).build());

Again, to ensure maximum flexibility of document sources, PSPDFKit comes with an extensible class to provide a custom data provider that’s writable.

Writing a data provider inheriting from WriteableDataProvider will allow you to sink data to any source possible (e.g. cloud providers, in-memory, encrypted sources).