Image height and weight

Hi,

I am trying to add image to pdf document. I have a image which is 86px height and 100px width. But image looks bigger than specified measurements when it is rendered on the page. How can we fix this?

This is how I am specifying it.
Image img = new Image();
img.setFile(“d:/pdf/logo.png”);
img.setFixHeight(86);
img.setFixWidth(100);

Thanks
Mamatha

Hi Mamatha,


Thanks for your inquiry. We will appreciate it if you please share your sample image and input/output PDF document, we will look into the issue and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regard,

Hi,



I have attached both image and pdf.

I have a table and I am inserting image into a table cell. I have noticed this behavior with all types of images.



Image logoimg = new Image();

logoimg.setFile(“d:/pdf/Question.png”);

logoimg.setFixHeight(49);

logoimg.setFixWidth(49);

cell.getParagraphs().add(logoimg);



Thanks

Mamatha

Hi Mamatha,


Thanks for sharing the sample image. I have tested the scenario with Aspose.Pdf for Java 11.2.0 and unable to notice the reported issue. Please download and try latest version of Aspose.Pdf for Java, it will resolve the issue.

com.aspose.pdf.Document doc = new
com.aspose.pdf.Document();<o:p></o:p>

com.aspose.pdf.Page page = doc.getPages().add();

com.aspose.pdf.Table table = new com.aspose.pdf.Table();

table.setColumnWidths("100 100");

page.getParagraphs().add(table);

table.setBorder(new com.aspose.pdf.BorderInfo(com.aspose.pdf.BorderSide.All, com.aspose.pdf.Color.getHotPink()));

table.setDefaultCellBorder( new com.aspose.pdf.BorderInfo(com.aspose.pdf.BorderSide.All, com.aspose.pdf.Color.getIndigo()));

com.aspose.pdf.Row r1 = table.getRows().add();

com.aspose.pdf.Cell c1 = r1.getCells().add();

com.aspose.pdf.Image image = new com.aspose.pdf.Image();

image.setFile(myDir + "Question.png");

image.setFixHeight(49);

image.setFixWidth(49);

c1.getParagraphs().add(image);

com.aspose.pdf.Cell c2 = r1.getCells().add();

com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();

image1.setFixHeight(69);

image1.setFixWidth(69);

image1.setFile(myDir + "Question.png");

c2.getParagraphs().add(image1);

doc.save(myDir + "Image_tablecell.pdf");


Best Regards,