Foxit Quick PDF Library

Incremental Updates in PDF files

Incremental updates provide a method for updating a PDF file without completely re-writing it, according to the PDF specification (1.7), incremental updates work like this:

The contents of a PDF file can be updated incrementally without rewriting the entire file. Changes are appended to the end of the file, leaving its original contents intact.

This is illustrated in the diagram below:

Foxit Quick PDF Library provides full support for using an incremental update when making changes to a PDF. Incremental updates are useful in some cases and absolutely necessary in others. Usage scenarios:

  • Make small changes to large documents faster. Changes appended to the end of the file, rather than the entire file being re-written.
  • Minimize the risk of data loss when processing a PDF by appending changes to the original document at the end of the file rather than re-writing the entire file (alternative to this would be to just save a copy of original file instead of overwriting original — however, depending on circumstances this is not always possible).
  • Incremental updates are required when modifying a digitally signed PDF. Any changes to the existing bytes in the file will invalidate existing signatures, so re-writing the PDF is not an option.

The functions in Foxit Quick PDF Library which let you use an incremental update when saving PDF files is DAAppendFile when using the direct access functions and AppendToFile when using the regular functions.

Here are some C# examples of how to use the AppendToFile to incrementally update PDF files:

/* 1. Incremental updates when adding new content to a PDF */

// Create basic PDF
// Blank document is automatically loaded into
// memory and selected when you initialize Foxit Quick 
// PDF Library so we can use that without adding a new blank doc.
DPL.DrawText(100, 500, "Hello World 1"); // Draw some text on the doc
DPL.SaveToFile(@"original.pdf"); // Save copy for later comparison
DPL.SaveToFile(@"original_update.pdf"); // Save copy that we'll use for the incremental update

// Load the PDF, add new page, more text and save as incremental update
DPL.LoadFromFile(@"original_update.pdf", "");
DPL.NewPage(); // Adds second page to the document
DPL.SelectPage(2); // Selects the second page
DPL.DrawText(100, 500, "Hello World 2"); // Draw some new text on page 2
DPL.AppendToFile(@"original_update.pdf"); // AppendToFile instead of SaveToFile saves as incremental update

/* 2. Incremental updates when merging documents together */

// Create two basic PDFs to test with
DPL.DrawText(100, 500, "Hello World"); // Draw some text
DPL.SaveToFile(@"original1.pdf"); // Save the primary copy
DPL.SaveToFile(@"original2.pdf"); // Save copy we'll append to the primary doc

// Load the first pdf
DPL.LoadFromFile(@"original1.pdf", "");
int PrimaryDoc = DPL.SelectedDocument();

// Load the second pdf
DPL.LoadFromFile(@"original2.pdf", "");
int SecondaryDoc = DPL.SelectedDocument();

// Select the first document
DPL.SelectDocument(PrimaryDoc);

// Merge the second document with the
// previously selected document.
DPL.MergeDocument(SecondaryDoc);

// Save the merged document to disk
DPL.AppendToFile(@"original1.pdf");

This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.

Updated on May 16, 2022

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: