Incremental Saving in UWP
By default, PSPDFKit saves to files incrementally. This is a feature of PDF 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 are some examples of saving incrementally:
// Save incrementally by default. await pdfView.Document.ExportAsync(file); // Explicitly save incrementally. var exportOptions = new DocumentExportOptions{ Incremental = true }; await pdfView.Document.ExportAsync(file, exportOptions);
Here’s how to rewrite the PDF when saving:
// Set `Incremental` to `false` to rewrite the document. var exportOptions = new DocumentExportOptions{ Incremental = false }; await pdfView.Document.ExportAsync(file, exportOptions);
Note that you can also export a PDF with flattened annotations. However, flattening requires a full rewrite of the document, so the Incremental
property of DocumentExportOptions
is ignored if Flatten
is set to true
.