Linearize PDFs in C# .NET

Linearize a PDF when you want to optimize a PDF for Fast Web View mode. This means that the linearized PDF loads faster in a browser or other applications that stream the document from a remote server. The linearization process restructures a PDF document so that only the requested page is downloaded from the server, rather than the entire PDF. This is especially important with large documents that can take a long time to download.

To linearize a PDF document, follow these steps:

  1. Create a GdPicturePDF object.
  2. Load the source document by passing its path to the LoadFromFile method.
  3. Save the output in a linearized PDF document with the SaveToFile method. This method takes the following parameters:
    • FilePath — The path to the output PDF document.
    • PackDocument — Optional: A Boolean value that specifies whether to pack the PDF document. This reduces the file size but slows down the saving process.
    • Linearize — Set this parameter to true to linearize the output PDF document.
using GdPicturePDF gdPicturePDF = new GdPicturePDF();
// Load a PDF document to GdPicture.
gdPicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Save the loaded PDF document to a file.
gdPicturePDF.SaveToFile(@"C:\temp\output.pdf", true, true);

Used methods

Related topics