Save PDF files in C#

Incremental

If you have a large PDF file and you want to modify only a small part of the PDF, use the SaveToFileInc method of the GdPicturePDF class. This method enables the content of the PDF document to be updated incrementally without rewriting it entirely. As a result, small changes to a larger PDF document are saved faster.

The following code draws a black rectangle on the first page of a PDF document and saves the PDF document incrementally to a file:

using GdPicturePDF gdPicturePDF = new GdPicturePDF();
// Load a PDF document to GdPicture.
gdPicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Select the first page.
gdPicturePDF.SelectPage(1);
// Set the fill color to black.
gdPicturePDF.SetFillColor(0, 0, 0);
// Draw a filled rectangle on the entire page.
gdPicturePDF.DrawRectangle(
Left: 0, Top: 0,
Width: gdPicturePDF.GetPageWidth(),
Height: gdPicturePDF.GetPageHeight(),
Fill: true,
Stroke: false);
// Save the PDF document incrementally.
gdPicturePDF.SaveToFileInc(@"C:\temp\source.pdf");