How to convert PDF pages to Tiff image in WPF?

2013-09-20 03:34:54 Written by  Administrator
Rate this item
(10 votes)

Background

PDF is now widely used to represent document in independent specification. It encapsulates a complete description of a fixed-layout flat document, including the text, fonts and graphics and so on. Due to its powerful functions, it is difficult for developers to parse its format. Or more specifically, to parse content out from PDF document and convert it to different image format is a tough task for some developers. This article will help you solve this problem by using PDF document viewer component Spire.PDFViewer for WPF by 5 easy steps. Firstly, you can download Spire.PDFViewer for WPF.

Target

To convert a specified or random page including frames of images from PDF file to TIFF programmatically.

Step 1: To create WPF application in Visual Studio and reference Spire.PdfViewer.WPF dlls.

Set .NET 4 as target framework

Step 2: Instance an object of Spire.PdfViewer.Wpf.PdfDocumentViewer

[C#]
PdfDocumentViewer pdfViewer = new PdfDocumentViewer();

Step 3: Call the “LoadFromFile”of PdfDocumentViewer object and load a PDF file.

[C#]
pdfViewer.LoadFromFile ("sample.pdf");

Step 4: Create an array and save all pages of this PDF file.

[C#]
int[] pageNumbers=new int[pageCount];
            for (int i=0;i

Step 5: Save it to Tiff image format

[C#]
pdfViewer.SaveAsImage("sample.tiff",pageNumbers);

The following code snippet shows all the code when converting pdf page to tiff image:

[C#]
private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Instance an object of Spire.PdfViewer.Wpf.PdfDocumentViewer
            PdfDocumentViewer pdfViewer = new PdfDocumentViewer();
            //Load a pdf file 
            pdfViewer.LoadFromFile("sample.pdf");
            int pageCount = pdfViewer.PageCount;
            // create an array and save all pages of this PDF file.
            int[] pageNumbers=new int[pageCount];
            for (int i=0;i

Screenshot

wpf screenshot

Spire.PDFViewer for WPF is a powerful WPF PDF Viewer control which enables developers to display PDF documents with their WPF applications without Adobe Reader. It’s available to load and view PDF documents like PDF/A-1B, PDF/X1A, and even encrypted from stream, file and byte array with support for printing, zooming, etc.

Additional Info

  • tutorial_title: Convert PDF pages to Tiff in WPF
Last modified on Wednesday, 15 September 2021 03:37