We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to export the pages in PDF document to multi-page tiff image in WPF PDFViewer?

Platform: WPF |
Control: PdfViewer |
Published Date: August 1, 2016 |
Last Revised Date: July 28, 2021

You can export the pages in the PDF document to images and then convert the exported images to multi-page tiff image in WPF PDF Viewer.

The following code snippet illustrates the conversion of pages in the PDF document to multi-page tiff image:

C#:

//create an instance for PdfLoadedDocument
PdfLoadedDocument ldoc = new PdfLoadedDocument("../../Data/Manual.pdf");
//ExportAsImage method returns specified page in the PDF document as Bitmap image 
Bitmap[] images = ldoc.ExportAsImage(0, ldoc.Pages.Count - 1);
//Tiff conversion
ImageCodecInfo encoderInfo = GetEncoderInfo("image/tiff");
//Initialize EncoderParameters that contain specified number of Encoderparameter objects
EncoderParameters encoderParams = new EncoderParameters(2);
//Initialize EncoderParameter
EncoderParameter parameter = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionNone);
encoderParams.Param[0] = parameter;
//Initialize the new instance for EncoderParameter
parameter = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, (long)EncoderValue.MultiFrame);
encoderParams.Param[1] = parameter;
System.Drawing.Image tiff = null;
for (int i = 0; i < images.Length; i++)
{
   if (i == 0)
   {
      tiff = images[i];
      //Save the tiff image into local disk
      tiff.Save("../../Output/output.tiff", encoderInfo, encoderParams);
   }
   else
   {
      System.Drawing.Image image = images[i];
      //Initialize the new instance for EncoderParameter
      parameter = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, (long)EncoderValue.FrameDimensionPage);
      encoderParams.Param[1] = parameter;
      //Add the subsequent image to save into the local disk
      tiff.SaveAdd(image, encoderParams);
   }
}

View sample in GitHub.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile