---
title: "Save PDF file in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/save-a-file/pdf-local-storage/"
md_url: "https://www.nutrient.io/guides/dotnet/save-a-file/pdf-local-storage.md"
last_updated: "2026-05-26T09:21:30.408Z"
description: "Discover how to save PDF files in .NET with options for local storage, incremental saves, and streaming. Explore our comprehensive guide today!"
---

# Save PDF files in C#

### Overview

[Overview](https://www.nutrient.io/guides/dotnet/save-a-file/pdf.md)

### To Local Storage

[To Local Storage](https://www.nutrient.io/guides/dotnet/save-a-file/pdf-local-storage.md)

### Incremental

[Incremental](https://www.nutrient.io/guides/dotnet/save-a-file/pdf-incremental.md)

### To Stream

[To Stream](https://www.nutrient.io/guides/dotnet/save-a-file/pdf-stream.md)

### Incremental to Stream

[Incremental to Stream](https://www.nutrient.io/guides/dotnet/save-a-file/pdf-incremental-to-stream.md)

To save a PDF document to a file on your local machine, use the [`SaveToFile` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToFile.html) of the [`GdPicturePDF` class](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF.html).

Common parameters:

- `FilePath` — Output file path. If the file exists, it’s overwritten.

- `PackDocument` (optional) — Packs the PDF before saving (smaller file size, slower save).

- `Linearize` (optional) — Enables Fast Web View.

The Fast Web View mode makes it possible to download the content one page at a time from the web. This feature is useful for large documents.

`SaveToFile` returns a `GdPictureStatus`, which should always be checked.

Packing removes unused PDF objects and recompresses used objects. You can combine this with the [`RemoveUnusedResources` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~RemoveUnusedResources.html) before saving.

To save a PDF document to a file with packing and Fast Web View enabled, use the following code:

### C#

```csharp

using GdPicture14;
using System;

using GdPicturePDF gdPicturePDF = new GdPicturePDF();

GdPictureStatus status = gdPicturePDF.LoadFromFile(@"C:\temp\source.pdf");
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"LoadFromFile failed: {status}");
    return;
}

status = gdPicturePDF.SaveToFile(@"C:\temp\output.pdf", true, true);
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"SaveToFile failed: {status}");
}

```

### VB.NET

```vb

Imports GdPicture14

Using gdPicturePDF As New GdPicturePDF()
    Dim status As GdPictureStatus = gdPicturePDF.LoadFromFile("C:\temp\source.pdf")
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"LoadFromFile failed: {status}")
        Return
    End If

    status = gdPicturePDF.SaveToFile("C:\temp\output.pdf", True, True)
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"SaveToFile failed: {status}")
    End If
End Using

```

## Saving a password-protected PDF

Encrypting isn’t enabled for PDF/A documents.

You can set two password types for a PDF document:

- User password (open password) — Enables opening and viewing a PDF document.

- Owner password (master password or permissions password) — Enables a user to copy, edit, or print a PDF document.

Both password types can be set for the same PDF. This means there are four possible scenarios:

- No passwords are set — Anyone can open and edit a PDF document.

- User password is set — The PDF document can be opened after providing the password. After opening the file, the user can then edit the PDF document.

- Owner password is set — The PDF document can be opened without the password. The user may have limited access to printing, editing, and copying content depending on the permissions settings, unless they provide the owner password to remove those restrictions.

- Both user and owner passwords are set — The file can only be opened by providing either password. With the user password, access to printing, editing, and copying content might be restricted depending on the permission settings. With the owner password, the user has no restrictions and can print, edit, and copy content.

To save a password-protected PDF, use the [`SaveToFile` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToFile.html) overload with encryption parameters.

### C#

```csharp

using GdPicture14;
using System;

using GdPicturePDF gdPicturePDF = new GdPicturePDF();

GdPictureStatus status = gdPicturePDF.LoadFromFile(@"C:\temp\source.pdf");
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"LoadFromFile failed: {status}");
    return;
}

status = gdPicturePDF.SaveToFile(
    @"C:\temp\output.pdf",
    PdfEncryption.PdfEncryption128BitAES,
    "",
    "owner",
    CanPrint: true,
    CanCopy: true,
    CanModify: false,
    CanAddNotes: false,
    CanFillFields: true,
    CanCopyAccess: false,
    CanAssemble: false,
    CanPrintFull: false);

if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"SaveToFile (encrypted) failed: {status}");
}

```

### VB.NET

```vb

Imports GdPicture14

Using gdPicturePDF As New GdPicturePDF()
    Dim status As GdPictureStatus = gdPicturePDF.LoadFromFile("C:\temp\source.pdf")
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"LoadFromFile failed: {status}")
        Return
    End If

    status = gdPicturePDF.SaveToFile(
        "C:\temp\output.pdf",
        PdfEncryption.PdfEncryption128BitAES,
        "",
        "owner",
        CanPrint:=True,
        CanCopy:=True,
        CanModify:=False,
        CanAddNotes:=False,
        CanFillFields:=True,
        CanCopyAccess:=False,
        CanAssemble:=False,
        CanPrintFull:=False)

    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"SaveToFile (encrypted) failed: {status}")
    End If
End Using

```
---

## Related pages

- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-pdf.md)
- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-jpg.md)
- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-tiff.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-bitmap.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-byte-array.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-ftp.md)
- [Save a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-xmp.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-vector.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-remote-url.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-incremental-to-stream.md)
- [Save images and PDF files in C#](/guides/dotnet/save-a-file.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-incremental.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-stream.md)

