Convert PDF to TIFF in C#

PDF to TIFF

To convert PDF documents to TIFF image files, choose one of the following options:

  • Create a multipage TIFF file from all the pages in the PDF document.
  • Create a single-page TIFF file from one page in the PDF document.

Creating a TIFF file from all pages in a PDF

To create a TIFF file from all pages in a PDF document, follow these steps:

  1. Create a GdPictureDocumentConverter object.
  2. Load the source image by passing its path to the LoadFromFile method. Recommended: Specify the source image format with a member of the DocumentFormat enumeration.
  3. Optional: Use the RasterizationDPI property of the GdPictureDocumentConverter object to specify the resolution, expressed in dots per inch (DPI), with which to convert raster images in the source PDF to vector images in the output TIFF file.
  4. Save the output TIFF file by passing its path to the SaveAsTIFF method. Optional: Specify the compression scheme used in the conversion with the TiffCompression enumeration.

The example below creates a TIFF file from a PDF document:

using GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter();
// Load the source document.
gdpictureDocumentConverter.LoadFromFile(@"C:\temp\source.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF);
// Configure the conversion.
gdpictureDocumentConverter.RasterizationDPI = 300;
// Save the output in a new TIFF file.
gdpictureDocumentConverter.SaveAsTIFF(@"C:\temp\output.tiff", TiffCompression.TiffCompressionAUTO);

Creating a TIFF file from a PDF page

To create a TIFF image from a page in a PDF document, follow these steps:

  1. Create a GdPicturePDF object and a GdPictureImaging object.
  2. Load the source document by passing its path to the LoadFromFile method of the GdPicturePDF object.
  3. Select the page that you want to convert to an image with the SelectPage method of the GdPicturePDF object.
  4. Render the selected page to a 200 dots-per-inch (DPI) image with the RenderPageToGdPictureImageEx method of the GdPicturePDF object.
  5. Save the output in a new TIFF image with the SaveAsTIFF method. Specify the compression scheme used in the conversion with the TiffCompression enumeration.

The example below creates a TIFF image from the first page of a PDF document:

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Load the source PDF document.
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Select the first page of the PDF.
gdpicturePDF.SelectPage(1);
// Render the selected page to an image.
int imageId = gdpicturePDF.RenderPageToGdPictureImageEx(200, true);
// Save the output in a new TIFF image.
gdpictureImaging.SaveAsTIFF(imageId, @"C:\temp\output.tiff", TiffCompression.TiffCompressionAUTO);
// Release unnecessary resources.
gdpictureImaging.ReleaseGdPictureImage(imageId);
gdpicturePDF.CloseDocument();