Foxit Quick PDF Library

Create a multi-page PDF from a multi-page TIFF programmatically

Using Foxit Quick PDF Library you can programmatically convert a multi-page TIFF image to a multi-page PDF. Here is some C# sample code that shows you how it’s done.

The size of the image drawn onto the PDF is determined by the DPI value of the image (if present). The ImageHorizontalResolution and ImageVerticalResolution functions return the necessary DPI information.

DPL.NewDocument();

int pages = DPL.GetImagePageCount("image.tiff");
if (pages == 0)
pages = 1;

for (int i=1;i<=pages;i++)
{
if (i != 1)
DPL.NewPage();

int id = DPL.AddImageFromFile("image.tiff", i);

DPL.SelectImage(id);

int dpix = DPL.ImageHorizontalResolution();
int dpiy = DPL.ImageVerticalResolution();

if (dpix == 0) dpix = 72;
if (dpiy == 0) dpiy = 72;

double ImageWidthInPoints = (double)DPL.ImageWidth() / dpix * 72.0; // assumming dpi units
double ImageHeightInPoints = (double)DPL.ImageHeight() / dpiy * 72.0;

DPL.SetPageDimensions(ImageWidthInPoints, ImageHeightInPoints);
DPL.SetOrigin(1);
DPL.DrawImage(0, 0, ImageWidthInPoints, ImageHeightInPoints);

}

QP.SaveToFile("converted_tiff_image.pdf");

QP.RemoveDocument(QP.SelectedDocument());
}

This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.

Updated on May 16, 2022

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: