---
title: "Save PDF file in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/save-a-file/pdf-incremental-to-stream/"
md_url: "https://www.nutrient.io/guides/dotnet/save-a-file/pdf-incremental-to-stream.md"
last_updated: "2026-06-09T10:38:40.873Z"
description: "Explore methods for saving PDF files in .NET, including local storage, streaming, and incremental options. Enhance your file handling techniques 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)

If you have a large PDF in a `Stream` and only need to save small changes, use the [`SaveToStreamInc` method](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToStreamInc.html) of the [`GdPicturePDF` class](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF.html).

Incremental saving updates the PDF without fully rewriting it, which is usually faster for minor edits.

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

### C#

```csharp

using GdPicture14;
using System;
using System.IO;

using GdPicturePDF gdPicturePDF = new GdPicturePDF();
using Stream streamPDF = new FileStream(@"C:\temp\source.pdf", FileMode.Open, FileAccess.ReadWrite);

GdPictureStatus status = gdPicturePDF.LoadFromStream(streamPDF);
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"LoadFromStream failed: {status}");
    return;
}

status = gdPicturePDF.SelectPage(1);
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"SelectPage failed: {status}");
    return;
}

status = gdPicturePDF.SetFillColor(0, 0, 0);
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"SetFillColor failed: {status}");
    return;
}

status = gdPicturePDF.DrawRectangle(
    0,
    0,
    gdPicturePDF.GetPageWidth(),
    gdPicturePDF.GetPageHeight(),
    true,
    false);
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"DrawRectangle failed: {status}");
    return;
}

status = gdPicturePDF.SaveToStreamInc(streamPDF);
if (status!= GdPictureStatus.OK)
{
    Console.WriteLine($"SaveToStreamInc failed: {status}");
}

```

### VB.NET

```vb

Imports GdPicture14
Imports System.IO

Using gdPicturePDF As New GdPicturePDF(),
      streamPDF As Stream = New FileStream("C:\temp\source.pdf", FileMode.Open, FileAccess.ReadWrite)

    Dim status As GdPictureStatus = gdPicturePDF.LoadFromStream(streamPDF)
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"LoadFromStream failed: {status}")
        Return
    End If

    status = gdPicturePDF.SelectPage(1)
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"SelectPage failed: {status}")
        Return
    End If

    status = gdPicturePDF.SetFillColor(0, 0, 0)
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"SetFillColor failed: {status}")
        Return
    End If

    status = gdPicturePDF.DrawRectangle(
        0,
        0,
        gdPicturePDF.GetPageWidth(),
        gdPicturePDF.GetPageHeight(),
        True,
        False)
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"DrawRectangle failed: {status}")
        Return
    End If

    status = gdPicturePDF.SaveToStreamInc(streamPDF)
    If status <> GdPictureStatus.OK Then
        Console.WriteLine($"SaveToStreamInc failed: {status}")
    End If
End Using

```
---

## Related pages

- [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 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-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 images in C#](/guides/dotnet/save-a-file/imaging-remote-url.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging-vector.md)
- [Save images in C#](/guides/dotnet/save-a-file/imaging.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 a file from the annotation manager in C#](/guides/dotnet/save-a-file/annotation-to-pdf.md)
- [Save PDF files in C#](/guides/dotnet/save-a-file/pdf-local-storage.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)

