Remove pages from PDFs in C#

Nutrient .NET SDK (formerly GdPicture.NET) enables you to remove pages from PDF files and multipage TIFF files.

To remove the second-to-last page of a PDF file, use the following code:

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Remove second-to-last page.
gdpicturePDF.DeletePage(gdpicturePDF.GetPageCount() - 1);
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

To remove the first page of a TIFF file, use the following code:

GdPictureImaging gdpictureImage = new GdPictureImaging();
int imageID = gdpictureImage.TiffCreateMultiPageFromFile(@"C:\temp\source.tif");
// Remove first page.
gdpictureImage.TiffDeletePage(imageID, 1);
gdpictureImage.TiffSaveMultiPageToFile(imageID, @"C:\temp\output.tif",
TiffCompression.TiffCompressionAUTO);
gdpictureImage.ReleaseGdPictureImage(imageID);