Hi There,
I am using the following code snippet to convert a tif file to pdf. The original tif file size is around 40 KB whereas the pdf file size is close to 2 MB. This happens for other tif files too. Another sample I tried, the tif file is 3 MB and pdf is 51 MB. Please let me know why the pdf file size is so huge and how to reduce it. I am using Aspose PDF 19.2 for Java version for this conversion.
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(“35860007_0001.0002.TIF”);
java.awt.image.BufferedImage bImage = null;
bImage = javax.imageio.ImageIO.read(new File(“12-1735-0616-8-003.TIF”));
page.getPageInfo().setHeight(bImage.getHeight());
page.getPageInfo().setWidth(bImage.getWidth());
// Set margins so image will fit, etc.
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setLeft(0);
page.getPageInfo().getMargin().setRight(0);
Image image1 = new Image();
// Add the image into paragraphs collection of the section
page.getParagraphs().add(image1);
// Set the image file stream
image1.setImageStream(fs);
doc.save(“35860007_0001.0002.TIF.pdf”);
Find attached the tif file and the output pdf file for your reference.
Thanks,
Mani
35860007_0001.0002.zip (5.1 MB)