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();
ir.setInput(iis);
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);
sec1.getParagraphs().add(img1);
img1.getImageInfo().setImageStream(new ByteArrayInputStream(os.toByteArray()));
img1.getImageInfo().setImageFileType(ImageFileType.Tiff);

}
pdf1.save(byteOut);
iis.close();


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

Hi,

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.