Quantcast
Channel: PDF tips & tricks
Viewing all articles
Browse latest Browse all 125

How to perform an incremental update for PDF document

$
0
0

Introduction


The PDF specification defines an incremental update in section “7.5.6 Incremental Updates” as an update to document’s content that doesn’t overwrite the original data, leaving it intact.  It simply adds new content to the end of the file, and updates its cross-reference table, making it aware that the new version of content is available.

The main benefit is that small changes to the large and weighty documents can be saved quickly, and it also makes it possible to update remote files without pushing the entire contents.


The code


Apitron PDF Kit .NET component fully supports incremental updates and makes you able to save changes in a very convenient manner, see the code below:

publicvoid PerformIncrementalUpdate()
{
    // open PDF file
    using (Stream stream = File.Open("document.pdf", FileMode.Open))
    {
        // create PDF document object based on stream
        FixedDocument doc = newFixedDocument(stream);
      
        // add new page
        doc.Pages.Add(newPage());

        // save as incremental update
        doc.Save();
    }
}

That’s it, and it’s important to note that the update becomes written to the original stream.


Conclusion



Whenever you need to manipulate PDF, you may count on Apitron PDF Kit .NET component - it just works, has superior support and detailed documentation (browse our blog, read the free bookor check out the online documentation section). If you have questions or need any help with the API, just let us know and we’ll provide you with a detailed reply including code samples if needed.

Viewing all articles
Browse latest Browse all 125

Trending Articles