This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/save-a-file/pdf-incremental-to-stream.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Save PDF file in C# .NET | Nutrient .NET SDK
Incremental to Stream

If you have a large PDF in a Stream and only need to save small changes, use the SaveToStreamInc method of the GdPicturePDF class.

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:

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