Free Support Forum - aspose.com

JPEG image invisible in PDF

Hi,


I join JPEG image that do not appears in PDF file. Image is encapsulated in cell’s table.

It usually works except with this image.

I use Aspose PDF 3.1 jdk16

My code:

pdf = new Pdf();
Section seccion = pdf.getSections().add();
pdf.setAuthor(“I”);
pdf.setCreator(“I”);
pdf.setSubject(“my subject”));
pdf.setTitle(bundle.getString(“asuntoBono”));
seccion.getPageInfo().getMargin().setLeft(45.0f);
seccion.getPageInfo().getMargin().setRight(45.0f);

Table tablaDC = new Table();
tablaDC.setColumnCount(2);
tablaDC.setColumnWidths(“50% 50%”);
seccion.getParagraphs().add(tablaDC);
Row filaDC = tablaDC.getRows().add();
Cell celdaDC = filaDC.getCells().add();
celdaDC.setAlignment(AlignmentType.Left);
celdaDC.setVerticalAlignment(VerticalAlignmentType.Top);
celdaDC.setPadding(margen);
celdaDC.setNoBorder(true);

Image imagen = new Image();
imagen.getImageInfo().setImageFileType(ImageFileType.Jpeg);
f = new File(“logo.jpg”);
imagen.getImageInfo().setFile(f.getAbsolutePath());
imagen.setImageScale(0.75f);
celdaDC.getParagraphs().add(imagen);



awaiting your response,

cheers,

Hi Jerome.

Thanks for your query. It seems that your query is related to Aspose.Pdf product. I am moving this thread to Aspose.Pdf forum. My colleagues will reply you shortly.

Hello Jerome,


Thanks for using our products.

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as
PDFJAVA-33154. We will investigate this
issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Hi Jerome.


Thanks for your patience.

We have further investigated the problem reported earlier as PDFJAVA-33154 and have figured our the reasons of this issue. Please note that the standard Java JPEG codec is not able to deal with JPEG files with EXIF APP1 markers. We have made some changes in Aspose.Pdf for Java and with the release of v3.3.0, it will use ImageIO codec to read such files. There is two possible workarounds for such files now:

  • try saving the file without a thumbnail preview
  • try read it by ImageIO codec:
Please try using the following code snippet to resolve this issue.

[Java]

Pdf pdf = new Pdf();<o:p></o:p>

Section seccion = pdf.getSections().add();

pdf.setAuthor("I");

pdf.setCreator("I");

pdf.setSubject("my subject");

pdf.setTitle("asuntoBono");

seccion.getPageInfo().getMargin().setLeft(45.0f);

seccion.getPageInfo().getMargin().setRight(45.0f);

Table tablaDC = new Table();

tablaDC.setColumnCount(2);

tablaDC.setColumnWidths("50% 50%");

seccion.getParagraphs().add(tablaDC);

Row filaDC = tablaDC.getRows().add();

Cell celdaDC = filaDC.getCells().add();

celdaDC.setAlignment(aspose.pdf.AlignmentType.Left);

celdaDC.setVerticalAlignment(aspose.pdf.VerticalAlignmentType.Top);

//celdaDC.setPadding(.5f);

celdaDC.setNoBorder(true);

BufferedImage image = ImageIO.read(new File("D:/pdftest/Logo.jpg"));

Image imagen = new Image();

imagen.getImageInfo().setImageFileType(ImageFileType.Jpeg);

imagen.getImageInfo().setSystemImage(image);

imagen.setImageScale(0.75f);

celdaDC.getParagraphs().add(imagen);

pdf.save("D:/pdftest/ImageInPdf-Logo.pdf");

The issues you have found earlier (filed as PDFJAVA-33154) have been fixed in Aspose.Pdf for Java 3.3.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan