How do I convert multipage TIFFs to PDF?


How do I convert multipage TIFFs to PDF?
You can use PDFNet to convert multipage tiffs to PDF.

pdftron.PDF.Image.Create(filename) method will embed only the first
image in the TIFF file (see AddImage sample project, however you can
use pdftron.PDF.Image.Create(System.Drawing.Bitmap) to import TIFF
images frame by frame.

In this case, Image.SelectActiveFrame() method from DotNet Framework
is useful to select the 'current' image. See for more
information and some sample code on how to use this API.

GDI+ does have some limitations when it comes to TIFF support (e.g.
CMYK images etc). As a workaround, you can use any third party TIFF or
image library (such as libtiff - http:// or freeimage
- that can load TIFF without relying
on GDI+. In this case you would decompress the Tiff file, frame by
frame, in memory and would pass the RAW image data to
pdftron.PDF.Image.Create() method).

The code used to load TIFF using freeimage might be along the
following lines:

// Assuming you are developing in C#:
string img1 = @"C:\image.tif";
Int32 fi =
  (int)FreeImageAPI.LoadSaveFlags.TIFF_RGB |
(int)FreeImageAPI.LoadSaveFlags.TIFF_NONE );
UInt32 hmem = FreeImageAPI.FreeImage.OpenMemory(null,0);

fi,hmem,(int)FreeImageAPI.LoadSaveFlags.TIFF_CMYK |

System.IntPtr ptr = IntPtr.Zero;
int size_in_bytes = 0;
FreeImage.AcquireMemory(hmem,ref ptr,ref size_in_bytes);
byte[] content = new byte[size_in_bytes];
Marshal.Copy(ptr ,content,0,(content.Length));

// And then embed the raw (and compress) image data using PDFNet API.

pdftron.PDF.Image img = Image.Create(doc.GetSDFDoc(),content,
600,900,8,ColorSpace.CreateDeviceRGB() ,0);
Element element_new = f.CreateImage(img, new Matrix2D(143, 0, 0, 215,
215, 387)); writer.WritePlacedElement(element_new);

Is there anyway you can send me the VB.Net code to do this?

The VB.NET code would be along the following lines:

Dim image As System.Drawing.Bitmap = System.Drawing.Image.FromFile("c:
Dim index As Guid = image.FrameDimensionsList(0)
Dim dimension As System.Drawing.Imaging.FrameDimension = New

' The number of frames in the file
Dim totalFrame As Integer = TifImage.GetFrameCount(dimension)
Dim currentFrame As Integer = 0

'select the page you want to process
image.SelectActiveFrame(dimension, currentFrame)

' Add the selected frame to the PDF file
... see AddImage sample project for details (
Dim img As Image = Image.Create(doc.GetSDFDoc(), image)
Dim element As Element = f.CreateImage(img, New Matrix2D(image.Width,
0, 0, image.Height, 50, 350))

Please note that we are not directly supporting GDI+, FreeType or
other third party libraries. For more information and some code
examples related to GDI+, please see