Hi Good day,
Prasad
Hi Good day,
Hi Prasad,
Thanks for your inquiry. We have tested your scenario with a new DOM approach. It is recommended to use the new approach as it is more improved and efficient. It is working fine with Duane.JPG. However, we have noticed an exception with IMG.JPG conversion, so logged a ticket PDFNEWJAVA-34775 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.
// instantiate Document object
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
// add page to PDF file
doc.getPages().add();
// create Image object
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
// load TIFF image
img.setFile(myDir + "Duane.jpg");
// add image to paragraphs collection of first page
doc.getPages().get_Item(1).getParagraphs().add(img);
// save resultant PDF
doc.save(myDir + "IMGDOM.PDF");
We are sorry for the inconvenience caused.
Best Regards,
Hi Good evening,
metropolitanhealth:
Hi Good evening,Could you pls provide some feedback for the issue we have raised earliler with regarding .jpg conversion to PDF.Below is the ticket number : PDFNEWJAVA-34775and thread link : metropolitanhealth:
metropolitanhealth:
we are still having issues with certain jpg files.Pls find the attached files that has .jpg files with in the email attachment.we are also having .TIF file conversion issues,pls find one sample one that failed in PRODUCTION
Hi good day,
Hi Prasad,
The issues you have found earlier (filed as PDFNEWJAVA-34775) have been fixed in Aspose.Pdf for Java 10.3.0.
Hi Good day,
Hi Prasad,
Thanks for your inquiry. As suggested in the earlier post, please use the new DOM approach for JPG to PDF conversion; it is fixed in it. I have tested your shared JPG images with the following code and was unable to notice the reported exception.
Moreover, we will notify you as soon as we resolve the reported issue (PDFNEWJAVA-34838), related to TIF image conversion.
// instantiate Document object
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
// add page to PDF file
doc.getPages().add();
// create Image object
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
// load TIFF image
img.setFile(myDir + "prod4.JPGF");
// add image to paragraphs collection of the first page
doc.getPages().get_Item(1).getParagraphs().add(img);
// save resultant PDF
doc.save(myDir + "prod4_IMGDOM.PDF");
Best Regards,
Hi good day,
I have tried your DOM Approach, please check below code as I am currently testing:
// New version using DOM approach
private static void convertImageToPdf(String inFilepath, String pdfFilepath, FileType fileType)
throws XPdfConvert {
LOG.info(" Converting Image To Pdf using DOM Approach .... ");
ByteArrayInputStream srcStream = null;
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
byte[] inbytesArray = null;
try {
inbytesArray = FileUtils.readFileToByteArray(new File(inFilepath));
srcStream = new ByteArrayInputStream(inbytesArray);
Pdf pdf1 = new Pdf();
// instantiate Document object
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
// add page to PDF file
doc.getPages().add();
com.aspose.pdf.Image img1 = new com.aspose.pdf.Image();
img1.setImageStream(srcStream);
// add image to paragraphs collection of first page
doc.getPages().get_Item(1).getParagraphs().add(img1);
pdf1.save(dstStream);
LOG.info(" Converted Image To Pdf by ASPOSE Successfully ");
} catch (Exception e) {
LOG.error("Failed to convert Image to PDF... Error message: " + e.getMessage() + ". Error cause: " + e.getCause());
throw new XPdfConvert(String.format("message=\"Failed to convert Image file To PDF '%s'\"", inFilepath), e);
}
}
Please assist with this ASAP as this is a PROD issue. Please send me the converted PDFs that you have mentioned were working with my JPEG files attached earlier.
The code snippet that you have given earlier is the one I shared some time before, which was not working. So, I am a bit confused.
Your code:
// instantiate Document object
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
// add page to PDF file
doc.getPages().add();
// create Image object
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
// load TIFF image
img.setFile(myDir + "prod4.JPGF");
// add image to paragraphs collection of first page
doc.getPages().get_Item(1).getParagraphs().add(img);
// save resultant PDF
doc.save(myDir + "prod4_IMGDOM.PDF");
We are still waiting for the TIF image conversion issue related to TIF image conversion to PDFNEWJAVA-34838.
Your response will be appreciated,
Kind Regards,
Prasad
Hi Prasad,
metropolitanhealth: I have tried your DOM Approach, pls check below code as i am currently tested:
//New version using DOM approach private static void convertImageToPdf(String inFilepath, String pdfFilepath,FileType fileType) throws XPdfConvert { LOG.info(" Converting Image To Pdf using DOM Approach .... " ); ByteArrayInputStream srcStream = null; ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); byte[] inbytesArray = null; try { inbytesArray = FileUtils.readFileToByteArray(new File(inFilepath)); srcStream = new ByteArrayInputStream(inbytesArray); Pdf pdf1 = new Pdf(); // instantiate Document object com.aspose.pdf.Document doc = new com.aspose.pdf.Document(); // add page to PDF file doc.getPages().add(); com.aspose.pdf.Image img1 = new com.aspose.pdf.Image(); img1.setImageStream(srcStream); //add image to paragraphs collection of first page doc.getPages().get_Item(1).getParagraphs().add(img1); pdf1.save(dstStream); LOG.info(" Converted Image To Pdf by ASPOSE Successfully " ); } catch (Exception e) { LOG.error("Failed to convert Image to PDF... Error message: "+e.getMessage()+". Error cause: "+e.getCause()); throw new XPdfConvert(String.format("message=\"Failed to convert Image file To PDF '%s'\"", inFilepath),e); } }
Pls assist with this ASAP as this is a PROD issue.
Thanks for your inquiry. Please note you are mixing old generator and new generator in above code. You have added image to PDF using new DOM but at the end saving old generator object. That results in a blank PDF. Please remove above highlighted code lines and save PDF to stream using doc.save()
method. It will resolve the issue.
metropolitanhealth: Pls send me the converted pdf’s that you have mentioned that it was working with my JPEG files attached earlier.
We have already shared the subjected PDFs in above post.
metropolitanhealth: The code snippet that you have given earlier is the one i shared some time before which was not working.so bit confused.
Your code:
// instantiate Document object com.aspose.pdf.Document doc = new com.aspose.pdf.Document(); // add page to PDF file doc.getPages().add(); // create Image object com.aspose.pdf.Image img = new com.aspose.pdf.Image(); // load TIFF image img.setFile(myDir+"prod4.JPGF"); // add image to paragraphs collection of first page doc.getPages().get_Item(1).getParagraphs().add(img); // save resultant PDF doc.save(myDir+"prod4_IMGDOM.PDF");
We are still waiting for the TIF issue related to TIF image conversion (PDFNEWJAVA-34838).
Your response will be appreciated,
Kind Regards,
Prasad
Please pay attention, actually you shared old generator (aspose.pdf
) code in your initial post and we are suggesting you new DOM code (com.aspose.pdf
), both are different.
Moreover, regarding PDFNEWJAVA-34838, we will notify as soon as we make some significant progress toward issue resolution.
Best Regards,
Hi,
Good day,
Thank your for the assistance by pointing to the right piece of code for JPEG conversion with the latest aspose.pdf jar, and I have tested JPEG files which failed earlier.
With regards to PDFNEWJAVA-34838, did you make any progress on this?
Please let me know once you have a solution that fixes converting certain TIFF files that failed as per my earlier email.
Your response will be appreciated.
Thank you once again for the support.
Kind regards,
Prasad
Hi Prasad,
metropolitanhealth:
Thank you for the assistance by pointing to the right piece of code for JPEG conversion with the latest aspose.pdf jar. I have tested JPEG files which failed earlier.
I am afraid I am not clear by your statement. Does it mean the JPEG conversion issue is resolved?
metropolitanhealth:
Regarding PDFNEWJAVA-34838, did you guys make any progress on this? Please let me know once you have a solution that fixes converting certain tiff files that failed as per my email earlier.
In reference to PDFNEWJAVA-34838, the issue is still not resolved. Our product team has completed the initial investigation and planning for the resolution. We will notify you as soon as we make some significant progress towards issue resolution.
Thanks for your patience and cooperation.
Best Regards,
Hi Good day,
metropolitanhealth:
Hi Good day,Sorry for the confusion,I mean to say issue with JPEG files was resolved with new DOM Approach.Just waiting for the solution for TIFF image conversion.Hi Prasad,Please note that the issue reported earlier as PDFNEWJAVA-34838 is regarding TIFF to PDF conversion, whereas the previously reported issue was related to JEPG to PDF conversion.As shared by Tilal, as soon as we have we have made some definite progress towards the resolution of TIFF image to PDF conversion, we will let you know.
The issues you have found earlier (filed as PDFNEWJAVA-34838) have been fixed in Aspose.Pdf for Java 11.4.0.