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

Free Support Forum - aspose.com

MultiPage Tiff to PDF

I am using the following code to convert multi page tiff to pdf but the final size of pdf is very huge.
The input tiff has 24 pages and is of size 2.5 MB
The final converted file is of 480MB which is way tooooo much. I need an approach to convert tiff to pdf with minimal final size.

Code i am using:

public OutputStream convertMultiTiffToPdf(InputStream sourceFile) throws Exception{
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
try {
log.debug(“start of convertTIFFoPDF”);

ImageInputStream iis = ImageIO.createImageInputStream(sourceFile);
Iterator readers = ImageIO.getImageReaders(iis);
ImageReader ir = readers.next();
int frameCount = ir.getNumImages(true);
Pdf pdf1 = new Pdf();
for(int i=0;i<frameCount;++i){
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(ir.read(i), “jpg”, os);
//Create a section in the Pdf object
Section sec1 = pdf1.getSections().add();
aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
img1.getImageInfo().setImageStream(new ByteArrayInputStream(os.toByteArray()));


log.debug(“Pages for current Tiff :” + pdf1.getPageCount());
}catch (Exception ex) {
log.error(null, ex);
log.error(“Exception occurred in convertTIFFoPDF”
+ ex.getMessage());
throw new Exception(ex);
} finally {

log.debug(“END of convertTIFFoPDF”);
return byteOut;


Thanks for contacting support.

Can you please share the input TIFF image, so that we can test the scenario in our environment. We are sorry for this inconvenience.