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:
- Create a
GdPictureDocumentConverterobject. - Load the source image by passing its path to the
LoadFromFilemethod. Recommended: Specify the source image format with a member of theDocumentFormatenumeration. - Optional: Use the
RasterizationDPIproperty of theGdPictureDocumentConverterobject 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. - Save the output TIFF file by passing its path to the
SaveAsTIFFmethod. Optional: Specify the compression scheme used in the conversion with theTiffCompressionenumeration.
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);Using gdpictureDocumentConverter As 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)End UsingRelated topics
Creating a TIFF file from a PDF page
To create a TIFF image from a page in a PDF document, follow these steps:
- Create a
GdPicturePDFobject and aGdPictureImagingobject. - Load the source document by passing its path to the
LoadFromFilemethod of theGdPicturePDFobject. - Select the page that you want to convert to an image with the
SelectPagemethod of theGdPicturePDFobject. - Render the selected page to a 200 dots-per-inch (DPI) image with the
RenderPageToGdPictureImageExmethod of theGdPicturePDFobject. - Save the output in a new TIFF image with the
SaveAsTIFFmethod. Specify the compression scheme used in the conversion with theTiffCompressionenumeration.
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();Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()Using gdpictureImaging As 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. Dim imageId As Integer = 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()End UsingEnd UsingRelated topics