TIFF, also known as TIF, is a computer file format that stores raster graphics. This image format is supported by a large amount of applications such as image-manipulation, publishing, page layout, scanning, faxing, word processing, and optical character recognition. Moreover, TIFF is quite popular among graphic artists, publishing industry, amateur, and professional photographers.
How to Convert PDF to TIFF for .NET
PDF, short for Portable Document Format, is a file format that presents document with factors like text, font, images and vector graphics in a manner independent of operating systems, hardware and applications. Software that reads, edits, or annotates Adobe PDF document is never rare. But feasible solutions, for converting PDF file to image in .NET program, especially for TIFF/TIF image format, is not as that easy to find.
In this article, we will walk you through the user-defined PDF to TIFF conversion in .NET application. In the first place, you will have an overview of Tiff image file, and then move on to how to get Tiff image file from PDF document.
Generally speaking, PDF to TIFF conversion needs the decoding of PDF document and encoding of TIFF image file. Then, the complexity of PDF data decoding and TIFF image encoding, as well as the data transaction and process integration, are very likely to spend you a lot of time and effort, especially when you are not familiar with PDF to TIFF/TIF conversion for .NET, C# and VB.NET programming.
Here, we would like to introduce you how to achieve quick and effective conversion from PDF document to TIFF image in .NET project. The conversion process is user-friendly by providing several customizable settings. Please firstly see system requirements as below.
System Requirement
- Support Windows XP, Windows Vista, Windows 7, and Windows 8 in 32/64-bit
- Support Windows Server 2003, 2008, and 2012 in 32/64-bit
- Support .NET Framework 2.0 and greater versions
- Support Microsoft Visual Studio 2005 and greater versions
- Support ASP.NET web project, .NET WinForms project, and Console application
Now, it's time to look into user-defined PDF converting properties and APIs, so that you can make your own customization in .NET project. Please note, Visual C# and Visual Basic programming languages are supported.
Define PDF File to Convert
In all, there are two ways to define a PDF file to read in your Visual Studio .NET project, including loading from a local PDF file and loading from a file stream or memory stream.
public bool LoadPDF(string fileName);
public bool LoadPDF(Stream stream);
Both of them will return true if your PDF file is loaded successfully, while false if failed to load.
Render TIFF Image from Target PDF Page
Before converting, developers may need the page count of PDF file. pqScan PDF to Image Converter Software for .NET supplies a solution for you. Please use the following code in your C# and VB.NET programming.
public int PageCount;
Then, you may use page index to choose a page of PDF document to convert to TIFF/TIF image file. Certainly, this .NET API can also be repeatedly used to change a range of PDF pages to several single page Tiff images. If your application requires to converting all PDF document pages to a multipage TIFF/TIF image file, you can refer to this online tutorial for specific API: convert all PDF pages to a multi-page TIFF.
public Bitmap ToImage(int pageIndex);
Set up DPI for Transformed TIFF Image
The quality of rendered TIFF/TIF image is based on DPI property setting. The DPI is higher, the image quality is greater.
public double DPI;
Get the Height and Width of PDF Page
.NET developers can get the original size of current PDF file page, which may help to decide how large would the output image size be.
public int GetPageHeight(int pageIndex);
public int GetPageWidth(int pageIndex);
Customize the Size of TIFF/TIF File
To resize TIFF image file, please set DPI property accordingly, and then change the width and height of output image using API below.
public Bitmap ToImage(int pageIndex, int width, int height);