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
GdPictureDocumentConverter
object. - Load the source image by passing its path to the
LoadFromFile
method. Recommended: Specify the source image format with a member of theDocumentFormat
enumeration. - Optional: Use the
RasterizationDPI
property of theGdPictureDocumentConverter
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. - Save the output TIFF file by passing its path to the
SaveAsTIFF
method. Optional: Specify the compression scheme used in the conversion with theTiffCompression
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);
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 Using
Related 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
GdPicturePDF
object and aGdPictureImaging
object. - Load the source document by passing its path to the
LoadFromFile
method of theGdPicturePDF
object. - Select the page that you want to convert to an image with the
SelectPage
method of theGdPicturePDF
object. - Render the selected page to a 200 dots-per-inch (DPI) image with the
RenderPageToGdPictureImageEx
method of theGdPicturePDF
object. - Save the output in a new TIFF image with the
SaveAsTIFF
method. Specify the compression scheme used in the conversion with theTiffCompression
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();
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 Using
Related topics