Ticket T458759
Visible to All Users

Document Conversion: PDF <-> TIFF

created 8 years ago

Hi,

Is there an easy and reliable way to convert a multi-page PDF document to a multi-page TIFF and vice versa? If so, can you point me in the right direction? Maybe a short sample code?

Thanks.

Answers approved by DevExpress Support

created 8 years ago

Hello Daniel,
You can use our PdfDocumentProcessor component for this purpose. To convert a PDF document to a multi-page Tiff image, create an instance of PdfDocumentProcessor, load the required document using the PdfDocumentProcessor.LoadDocument method and convert the loaded document to Tiff using the PdfDocumentProcessor.CreateTiff method.
There is no direct conversion from the Tiff to PDF format. However, you can retrieve all frames from the Tiff file as separate images, create a new PDF document using the Document Creation API and draw images on the document pages. I've attached a sample demonstrating how to create a PDF document using images from a Tiff image.
In addition, see the following link - How to extract frames from the multi-page Tiff image.
I hope that you find this information helpful.

    Show previous comments (17)
    DevExpress Support Team 8 years ago

      Hi Daniel,

      Thank you for your sharing your results. As for your next question, our Pdf Suite does not support  CCITT encoding for images, thus a resulting file may be larger. You can also test conversion into other image formats, for instance, JPEG, to produce the optimal result.

      I need to mention that we've researched the "DevExpress.pdf" file you provided, and it looks that this file was not produced by our Pdf Suite. Maybe, you attached a wrong file. Could you please check it?

      DP DP
      Daniel Programer 8 years ago

        I'm reattaching the PDF.

        Each page was originally created using a different library, but the final PDF was assembled using the code that you've provided. So, in the code snippet below, variable "Image" is a bitmap created using other 3rd party library.

        Most of the documents that I'm going to be dealing with are 1-bit scanned images (black and white). How can I optimize (reduce) the size of the output PDF? What are your plans on implementing CCITT compression? Do you have a specific date?

        Thanks.

        C#
        using (var graphics = processor.CreateGraphics()) { float targetWidth = (float)width / (float)resolution.X; float targetHeight = (float)height / (float)resolution.Y; var pageSize = new PdfRectangle(0, 0, targetWidth * 72, targetHeight * 72); graphics.DrawImage(image, new RectangleF(0, 0, targetWidth * 72, targetHeight * 72)); processor.RenderNewPage(pageSize, graphics, 72, 72); }
        DevExpress Support Team 8 years ago

          Thank you for your clarification, Daniel. We have not yet established our plans regarding this feature. If we decide to implement this feature, we will announce it using our news channels (What's New/blogs). You will not miss anything.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.