We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert Multipage tiff to multipage pdf


I am trying out Aspose Imaging for Java. I am trying to convert to multi page/frame tiff to multi page PDf. Can’t find any example.

Can any help with an example to how to do this



I have observed your requirements and suggest you to please visit this link to export each Tiff frame inside Tiff image to separate image. You can export to PDF using Pdfoptions while using tifframe.Save() method call.

Hi Mudassir,

Thanks for your reply.
The code sample you have linked is for .NET. I am looking for Java example.
Even in .NET example it is exporting individual images. and we will need to use Aspose PDF dependency just to be able to that. I need a simple export option like you have for djvu format with DjvuMultiPageOptions
Example :
" Converting DjVu to PDF Format" section in

And we want it to be single pdf with multiple page (1 page per frame). Not one PDF per tiff frame


Thank you for elaborating your requirements.

You may convert a multi-frame TIFF image to single multi-page PDF document using below code snippet with Aspose.PDF for Java.

// instantiate Document instance
Document doc = new Document();

// add blank page to pages collection of Document instance

// create Image object
com.aspose.pdf.Image image = new com.aspose.pdf.Image();
image.setFile(dataDir + "TestImage.tiff");

// add image to paragraphs collection of PDF page

// save resultant file
doc.save(dataDir + "Test_18.10.pdf");

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thanks @Farhan.Raza

Though the solution works, It doesn’t set proper page size and in my case images were stretched on page.
Before seeing your reply i already found a solution which sets page size also properly.

Adding my code also, this may help someone else on this forum in future looking for similar solution. This will allow them to choose any of these solutions as per their needs.

TiffImage image = (TiffImage) Image.load(imagePath);
		String pdfPath = imagePath + ".pdf";
		Document pdf = new Document();
		for (TiffFrame f : image.getFrames()) {
			com.aspose.pdf.Page page = pdf.getPages().add();
			com.aspose.pdf.Image img = new com.aspose.pdf.Image();
			page.setPageSize(f.getWidth(), f.getHeight());
			ByteArrayOutputStream output = new ByteArrayOutputStream();
			f.save(output, new JpegOptions());
			img.setImageStream(new ByteArrayInputStream(output.toByteArray()));

Also, This seems to be working for me. Still if you see anything that may cause problem please suggest a change as for now I have tested it with very limited set of images


Thank you for your valuable feedback.

We are glad to know that things are now working fine in your environment. Please keep using our APIs and in event of any further query, feel free to ask.