We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NullPointerException is thrown while converting html to pdf with links to some gif images

Hi,

We are trying to convert an html that has images to pdf. We are using aspose.pdf for java. In case of some gif images, the following exception is thrown:

Exception in thread "main" java.lang.NullPointerException
at com.aspose.pdf.internal.imaging.fileformats.gif.GifImage.hasTransparentColor(Unknown Source)
at com.aspose.pdf.internal.l8u.lb.drawImage(Unknown Source)
at com.aspose.pdf.internal.l8u.lt.drawImage(Unknown Source)
at com.aspose.pdf.internal.l38t.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0k.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.lv.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0j.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.lv.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l0if.lI(Unknown Source)
at com.aspose.pdf.internal.l27f.l1u.lI(Unknown Source)
at com.aspose.pdf.internal.l38t.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l47if.lI.lI(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.l6n.lI(Unknown Source)
at com.aspose.pdf.l6n.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.<init>(Unknown Source)
at com.aspose.pdf.Document.<init>(Unknown Source)

The sample html:

<html lang="en">
<head>
<title>gifs</title>
</head>
<body>
<div>
<img src="error_img.gif" alt="" />
    <!--	<img src="error_img2.gif" alt="" />-->
    <!--	<img src="giphy1.gif" alt="" />-->
   </div>
  </body>
  </html>

The sample gifs that cause an error:
gifs.zip (337.6 KB)

What is the problem with the images, is it a bug to be fixed by aspose?

@arjana3,

Thanks for contacting support.

Can you please share version details along with environment details and sample code so that we may further investigate this issue on our end to help you out.

aspose-pdf version: 20.2

The same exception occurred on two environments:

Microsoft Windows 10 Enterprise and CentOS 7
Java: OpenJDK 14.0.1 on both OS

Sample code:

HtmlLoadOptions options = new HtmlLoadOptions();
IDocument document = new Document(RESOURCE_DIR + "page_with_gifs.html", options);
document.save("result.pdf");

@arjana3,

I have observed your issue and like to inform that I have created investigation ticket with ID PDFJAVA-39467 in our issue tracking system to investigate and resolve this issue as soon possible.