This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/editor/manipulation/extract.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Extract page from PDF in C# .NET | Nutrient .NET SDK

Extracting pages is the process of selecting pages from a source document and then saving the selected pages in a new document.

Download sample

Extract pages from multipage files of the following formats:

Extracting pages from a PDF

The code below extracts pages from a multipage PDF file to a multipage output PDF file using the ClonePages method:

Register the SDK license before running SDK operations. For setup details, refer to the getting started with .NET SDK guide.

using GdPicture14;
LicenseManager license = new LicenseManager();
license.RegisterKEY("");
using GdPicturePDF gdpicturePDF = new GdPicturePDF();
using GdPicturePDF gdpictureDestPDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"input.pdf");
gdpictureDestPDF.NewPDF();
// Extract specified pages to the output file.
gdpictureDestPDF.ClonePages(gdpicturePDF, "2-3;5");
gdpictureDestPDF.SaveToFile(@"output.pdf");

To check whether the last operation succeeded, use the GetStat method of the GdPicturePDF object. It returns a member of the GdPictureStatus enumeration.

Extracting pages from a TIFF

The code below extracts pages from a multipage TIFF file to a multipage output TIFF file using the TiffExtractPage method. Each page is extracted separately:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int sourceImageID;
int outputID = 0;
int imageID;
string source = @"multipage-tiff.tif", output = @"output.tif";
sourceImageID = gdpictureImaging.CreateGdPictureImageFromFile(source);
// Set the page numbers you want to extract.
int[] pages = { 1, 3, 5 };
bool firstPage = true;
foreach (int page in pages)
{
Stream pStream = new MemoryStream();
gdpictureImaging.TiffExtractPage(sourceImageID, page, pStream);
// Move to the start of the stream before reading the extracted page.
pStream.Position = 0;
imageID = gdpictureImaging.CreateGdPictureImageFromStream(pStream);
if (firstPage)
{
// If it's the first image, create a new multipage TIFF file.
outputID = imageID;
gdpictureImaging.TiffSaveAsMultiPageFile(outputID, output, TiffCompression.TiffCompressionAUTO);
firstPage = false;
}
else
{
// If it's the second or later image, add to the previously created multipage TIFF file.
gdpictureImaging.TiffAddToMultiPageFile(outputID, imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
};
}
gdpictureImaging.TiffCloseMultiPageFile(outputID);
gdpictureImaging.ReleaseGdPictureImage(outputID);
gdpictureImaging.ReleaseGdPictureImage(sourceImageID);

To check whether the last operation succeeded, use the GetStat method of the GdPictureImaging object. It returns a member of the GdPictureStatus enumeration.