Free Support Forum - aspose.com

Conversion of Tiff To PDF

Dear Team

I have used below code for tiff to pdf. In this code pdf conversion is fine but output is not properly. Please give solution for this.

Source : Tiff to pdf.zip (467 Bytes)

Input : gr1.zip (379.1 KB)

Current OP : gr1_formate.zip (209.9 KB)

Expected OP : ExoOP.zip (414.7 KB)

Thank you

@ssvel

Thank you for contacting support.

Please upgrade to Aspose.PDF for Java 18.9.1 and try to use below code snippet in your environment, then share your kind feedback with us.

// Instantiate Document Object
Document doc = new Document();
// Add a page to pages collection of document
Page page = doc.getPages().add();
page.getPageInfo().setLandscape(true);
// Load the source image file to Stream object
java.io.FileInputStream fs = new java.io.FileInputStream("D:\\Tiff to pdf\\input\\gr1.tif");

// 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);

// Create an image object
com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();
// Add the image into paragraphs collection of the section
page.getParagraphs().add(image1);
// Set the image file stream
image1.setImageStream(fs);
// Save resultant PDF file
doc.save(dataDir + "TIFF2PDF_DOM.pdf");

We have attached generated PDF file for your kind reference TIFF2PDF_DOM.pdf. We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thanks for your support. It’s working fine.