Not able to write .png file in PDF

Hello,

In one of our application have pdf creation feature and in that we are writting multiple images in pdf , but when we select .png image then it throws error .
We have used the Aspose.Pdf for Android 1.6.0


The code which we have done for this is as below:


com.aspose.pdf.Image m_logo = new com.aspose.pdf.Image();
m_logo.setFile(AppConstant.APP_STORAGE_DIRECTORY + File.separator + "PDFImages" + File.separator + "header.png");
Page m_page = m_doc.getPages().add();
Table m_banner = new Table();

m_page.getParagraphs().add(m_banner);
m_banner.setColumnWidths("600");
Row m_row = m_banner.getRows().add();
m_row.isRowBroken(true);
com.aspose.pdf.Cell m_cell2 = m_row.getCells().add();
m_cell2.getParagraphs().add(m_logo);
Please let us know what we are doing wrong?

Hi there,


Thanks for your inquiry. I have tested the scenario with Aspose.Pdf for Android 1.6 and unable to notice any error. Please double check whether you are getting error with all PNG image or some specific one. We will appreciate it if you please share your sample PNG image and error details/message. So we will look into it and will guide you accordingly.

Document m_doc = new Document();

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

m_logo.setFile(imagepath);



Page m_page = m_doc.getPages().add();

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





m_page.getParagraphs().add(m_banner);

m_banner.setColumnWidths(“600”);



com.aspose.pdf.Row m_row = m_banner.getRows().add();
m_row.isRowBroken(true);

com.aspose.pdf.Cell m_cell2 = m_row.getCells().add();

m_cell2.getParagraphs().add(m_logo);

m_doc.save(outputPath);<o:p></o:p>


Best Regards,

Hi,


We are trying to write .png images to PDF but still we are facing the same issue and getting the error as below:

E/Bitmap.setPixels():1521īš• null
java.lang.IllegalStateException
at android.graphics.Bitmap.setPixels(Bitmap.java:1521)
at com.aspose.ms.System.Drawing.Image.save(Unknown Source)
at com.aspose.pdf.XImageCollection.m1(Unknown Source)
at com.aspose.pdf.XImageCollection.m8(Unknown Source)
at com.aspose.pdf.Page.m1(Unknown Source)
at com.aspose.pdf.Image.m1(Unknown Source)
at com.aspose.pdf.z24.m894(Unknown Source)
at com.aspose.pdf.Cell.m1(Unknown Source)
at com.aspose.pdf.Row.m1(Unknown Source)
at com.aspose.pdf.Row.m1(Unknown Source)
at com.aspose.pdf.Table.m1(Unknown Source)
at com.aspose.pdf.z24.m894(Unknown Source)
at com.aspose.pdf.Page.m4(Unknown Source)
at com.aspose.pdf.Page.m807(Unknown Source)
at com.aspose.pdf.ADocument.m807(Unknown Source)
at com.aspose.pdf.Document.m807(Unknown Source)
at com.aspose.pdf.ADocument.saveInternal(Unknown Source)
at com.aspose.pdf.Document.saveInternal(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)

But when we doing the same with .jpg image it is working fine. So please let us know what is the issue with .png images.

Thanks.

Hi there,


We are sorry for the delayed response. We have tested your source image using above shared code over Android Studio 1.2.2, but I am afraid I am unable to replicate the issue. Please share some more details so we can replicate the issue at our end and provide you information accordingly.

Best Regards,