PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2005/2008/2010/2012/2013

Convert A Multipage TIFF To PDF Using PDFOne .NET

Render each frame of the TIFF image on a PDF page.
By V. Subhash

There has been a lot of requests for code snippets that would do TIFF-to-PDF and PDF-to-TIFF conversions. In this article, we will see TIFF-to-PDF conversion using PDFOne .NET.

Unlike a BMP or JPEG image, TIFF is a container for multiple images. Using a TIFF viewer application such as Windows Picture and Fax Viewer or IrfanView, you can browse the individual frames. For a TIFF-to-PDF conversion, we need to extract the individual frames and render them on a page that is the same size as the frame. The following code example shows you how.

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Gnostice.PDFOne;
using System.Drawing.Imaging;


namespace PDFOne_dotNET_Examples {
  class Multipage_TIFF_To_PDF {
    static void Main(string[] args) {

      int i, n;

      // Load the TIFF image
      Bitmap bmp = new Bitmap("sample_doc.tiff");                                   
      // Find number of frames is the TIFF image
      n = bmp.GetFrameCount(FrameDimension.Page);

      PDFPage pg;
      PDFDocument doc = new PDFDocument("your-license-key");

      // Create a PDF page for each frame in the TIFF
      for (i = 0; i < n; i++) {
        // Active current frame
        bmp.SelectActiveFrame(FrameDimension.Page, i);
        // Create a PDF page with the same dimensions as the current TIFF frame
        pg = new PDFPage(bmp.Width/96,   // Assuming current 
                         bmp.Height/96,  // DPI is 96
                         PDFMeasurementUnit.Inches);
        // Render the current frame on the new page
        pg.DrawImage(bmp, 0f, 0f);
        // Add the page to document
        doc.AddPage(pg);
      }
      // Save the PDF document to file
      doc.Save("sample_doc.pdf");
      doc.Close();      

    }
  }
}
---oO0Oo---

Please note that we have another article for PDF-to-TIFF conversion.

---o0O0o---

Our .NET Developer Tools
Gnostice Document Studio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
Gnostice Document Studio Java

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved.