PDFtoolkit VCL
Edit, enhance, secure, merge, split, view, print PDF and AcroForms documents
Delphi C++Builder

Convert Multipage TIFF To PDF Using PDFtoolkit VCL

Exploiting a rarely used content-creation method.
By V. Subhash

PDFtoolkit VCL works on existing PDF documents. You don't create new PDF documents with it. But, it does have a method that allows you to insert a blank page to an existing PDF document.

public procedure InsertBlankPageAt(
    APageNumber: Integer; 
    PageWidth: Double; 
    PageHeight: Double

So, you could create a new PDF document from scratch by:

  1. Loading an existing PDF document;
  2. Inserting new blank pages using the InsertBlankPageAt() method; and
  3. Deleting all old pages.

Yes, it is quite a useful method. In this article, we will not go in that direction. Instead, we will use the InsertBlankPageAt() method to create pages that will hold images exported from a multi-page TIFF image.

Delphi Code Sample

Following is the source code of a Delphi console application. It uses Erik Van Bilsen's Delphi GDI+ library to extract frames from a multipage TIFF image. The extracted images are then rendered on to a blank PDF page inserted using InsertBlankPageAt().

program TIFF_To_PDF_With_eDocEngine;


  SysUtils, Classes, Windows, Graphics, jpeg,
  GdiPlus, GdiPlusHelpers, // Using Erik van Bilsen's Delphi GDI+ library
  gtPDFClasses, gtCstPDFDoc, gtExPDFDoc, gtExProPDFDoc, gtPDFDoc;

  TIFFImage: IGPImage;
  PageGuid: TGUID;
  Bitmap1: TBitmap;
  FrameCount, PageCount, I, J: Integer;
  PageRange: string;
  PageDimensions: TGPSizeF;
  gtPDFDocument1: TgtPDFDocument;
  gtImageWatermarkTemplate1: TgtImageWatermarkTemplate;

    // Load the mult-frame TIFF image
    TIFFImage := TGPBitmap.FromFile('multi_page.tiff');
    // Obtain the number of frames in the TIFF image
    PageGuid := FrameDimensionPage;
    FrameCount := TIFFImage.GetFrameCount(PageGuid);

    if PageCount > 0  then begin
      // Load an existing PDF document
      gtPDFDocument1 := TgtPDFDocument.Create(nil);

      // Find last page number
      J := gtPDFDocument1.PageCount;

      // Iterate through all frames in the TIFF image
      for I := 0 to FrameCount - 1 do begin
        // Select a frame
        // Obtain dimensins of current frame

        // Insert new page after last page - new page has same
        // dimension as current frame of TIFF image
        J := J + 1;

        // Save current frame to an temporary JPEG image
        TIFFImage.Save('temp_frame.bmp', TGPImageFormat.Bmp);

        // Load temporary image
        Bitmap1 := TBitmap.Create;

        // Render image on the new PDF page as an image watermark
        gtImageWatermarkTemplate1 := TgtImageWatermarkTemplate.Create;
        with gtImageWatermarkTemplate1 do begin
          X := 0;
          Y := 0;
          Image := Bitmap1;
          HorizPos := hpCenter;
          VertPos := vpMiddle;
        gtPDFDocument1.InsertWatermark(gtImageWatermarkTemplate1, IntToStr(J));

      // Save modified PDF document to a new file
      // Free resources

    on E: Exception do begin
      Writeln(E.ClassName, ': ', E.Message);


The above code used the following PDF document as the input file.

Bilsen's Delphi GDI+ library was used for extract frames from a multipage TIFF image.

After running the code, frames from the TIFF image were rendered new pages inserted into the PDF document.


Our .NET Developer Tools
Gnostice Document Studio .NET

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


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

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.