C#/VB.NET: Convert PDF to Linearized

PDF linearization, also known as "Fast Web View", is a way of optimizing PDF files. Ordinarily, users can view a multipage PDF file online only when their web browsers have downloaded all pages from the server. However, if the PDF file is linearized, the browsers can display the first page very quickly even if the full download has not been completed. This article will demonstrate how to convert a PDF to linearized in C# and VB.NET using Spire.PDF for .NET.

Install Spire.PDF for .NET

To begin with, you need to add the DLL files included in the Spire.PDF for.NET package as references in your .NET project. The DLLs files can be either downloaded from this link or installed via NuGet.

  • Package Manager
PM> Install-Package Spire.PDF

Convert PDF to Linearized

The following are the steps to convert a PDF file to linearized:

  • Load a PDF file using PdfToLinearizedPdfConverter class.
  • Convert the file to linearized using PdfToLinearizedPdfConverter.ToLinearizedPdf() method.
  • C#
  • VB.NET
using Spire.Pdf.Conversion;

namespace ConvertPdfToLinearized
{
    class Program
    {
        static void Main(string[] args)
        {
            //Load a PDF file
            PdfToLinearizedPdfConverter converter = new PdfToLinearizedPdfConverter("Sample.pdf");
            //Convert the file to a linearized PDF
            converter.ToLinearizedPdf("Linearized.pdf");
        }
    }
}
Imports Spire.Pdf.Conversion

Namespace ConvertPdfToLinearized
    Friend Class Program
        Private Shared Sub Main(ByVal args As String())
            'Load a PDF file
            Dim converter As PdfToLinearizedPdfConverter = New PdfToLinearizedPdfConverter("Sample.pdf")
            'Convert the file to a linearized PDF
            converter.ToLinearizedPdf("Linearized.pdf")
        End Sub
    End Class
End Namespace

Open the result file in Adobe Acrobat and take a look at the document properties, you can see the value of “Fast Web View” is Yes which means the file is linearized.

C#/VB.NET: Convert PDF to Linearized

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.