Conversion of PNG to PDF is failing

Hi,

I am trying below code to convert a specific PNG to PDF. But I get an exception. This is happening with a few PNG files, where as others work as expected.
Code:
com.aspose.pdf.Document document = new com.aspose.pdf.Document();
Page page = document.getPages().add();
com.aspose.pdf.Image image = new com.aspose.pdf.Image();
image.setImageStream(is); //“is” is inputstream.
page.getParagraphs().add(image);
document.save(baos, SaveFormat.Pdf);

Exception:
class com.aspose.pdf.internal.ms.System.l5if: Page have not room to place a paragraphs
com.aspose.pdf.ADocument.processParagraphs(Unknown Source)
com.aspose.pdf.Document.processParagraphs(Unknown Source)
com.aspose.pdf.ADocument.lf(Unknown Source)
com.aspose.pdf.ADocument.lj(Unknown Source)
com.aspose.pdf.ADocument.lf(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.Document.lI(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)image0011.png (11.1 KB)

@sushma1509,

I just executed the followinf code and it worked:

public void Logic() throws Exception
{
    File initialFile = new File(PartialPath + "_input.png");
    InputStream stream = new FileInputStream(initialFile);
    Image image = new Image();
    image.setImageStream(stream);

    var doc = new com.aspose.pdf.Document();
    var page = doc.getPages().add();
    page.getParagraphs().add(image);

    doc.save(PartialPath + "_output.pdf");

    System.out.println("ConvertPngToPdfTest Finished...");
}

Here is the output:
ConvertPngToPdf_output.pdf (21.6 KB)

I am wondering what version are you using? I am using Aspose.Pdf version 23.2

Hi @carlos.molina

Thanks for the response. I am using 23.1 version and I still see the issue.

@sushma1509,

I am not able to replicate the issue. Any other information you can share?

I am adding another sample file which gives me the same exception. imageStamp1.png (486 Bytes)

@sushma1509,

Code works fine(I tried mine, not yours, since yours is imcomplete). Here is the output:
ConvertPngToPdf_1_output.pdf (9.0 KB)

Can you try 23.2?

Beside that, there is not much I can help with as I already tried in 2 different machine the same code and works fine.