Using Debenu 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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());
}

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());
}