How do i convert a Multipage TIFF to a PDF



How do i convert a Multipage TIFF to a PDF

Multi-page TIFF images to PDF problem


Thanks for contacting support.

Please use following code snippet, in order to convert multi-page TIFF into PDF.

Document pdf1 = new Document();
MemoryStream ms = new MemoryStream();
new FileStream(dataDir + @"WO02006172A1.tif", FileMode.Open).CopyTo(ms);
Bitmap myimage = new Bitmap(ms);

FrameDimension dimension = new FrameDimension(myimage.FrameDimensionsList[0]);
int frameCount = myimage.GetFrameCount(dimension);

for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
 Page sec = pdf1.Pages.Add();

 myimage.SelectActiveFrame(dimension, frameIdx);

 MemoryStream currentImage = new MemoryStream();
 myimage.Save(currentImage, ImageFormat.Tiff);

 Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
 imageht.ImageStream = currentImage;
pdf1.Save(dataDir + "TifftoPDF.pdf");

In case you face any issue, please share your sample TIFF file with us, so that we can test the scenario in our environment and address it accordingly.



using this code i can only convert the first page to PDF. Is it possible that there is an issue with the code ?



Thanks for getting back to us.

We have tested above code snippet with one of our sample TIFF images and found it correct. Would you please share your sample TIFF image with us. We will test the scenario in our environment and address it accordingly.


How can I do the same in Aspose.Pdf Java? I’m using 19.4 version.



Please use following Java code to achieve functionality:

try {
     Document doc = new Document();
     // Add a page to pages collection of document
     Page page = doc.getPages().add();
     // Load the source image file to Stream object
     FileInputStream fs = new FileInputStream(dataDir + "input.TIF");

     java.awt.image.BufferedImage bImage = null;
     bImage = File(dataDir + "input.TIF"));

     // Set margins so image will fit, etc.
     Image image1 = new Image();
     // Add the image into paragraphs collection of the section
     // Set the image file stream
     image1.setImageStream(fs); + "output.pdf");
}catch (Exception ex){


Assuming the source tiff is “input.TIF”, what is “12-1735-0616-8-003.TIF”?



We are sorry for the confusion.

Both names should be of same TIFF image. We have now edited the code snippet in our previous reply.