# 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.

### C#

```csharp

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);

```

### VB.NET

```vb

Using gdPicturePDF As 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)
End Using

```

#### Used methods

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SaveToFile.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

---

## Related pages

- [Optimize PDFs using C#](/guides/dotnet/optimization.md)
- [Image and PDF compression in C#](/guides/dotnet/optimization/compress.md)
- [MRC compression in C#](/guides/dotnet/optimization/hyper-compress-mrc.md)
- [Flatten PDFs in C# .NET](/guides/dotnet/optimization/flatten.md)

