An image in the html does not appear in the pdf after conversion using java

Hello,

we are using the aspose pdf for java to convert html to pdf in our product. One of our customers is complaining that an image does not appear in the output pdf. The source of the image is an https link to the image file < img src=“https://…/logo.png” /> I tried to save the image to a file and use a relative path to the file, and the image appears in the output pdf, no problems.

I am attaching the source html with the problem image to the topic. What can be wrong with the image when its source is the provided link? I had had several reports about missing other images when their sources are https links so I thought there may be issues with https links but I cannot reproduce the problem with those images after upgrading to the 21.8 aspose version.

The html displays the image correctly.

Input html: input.zip

The code used to convert html to pdf:

HtmlLoadOptions options = new HtmlLoadOptions();
IDocument document = new Document("input.html", options);
document.save("output.pdf");

Thank you

Arjana Bivainiene

@arjana

We were able to reproduce the issue in our environment while using 22.3 version of the API. Therefore, it has been logged as PDFJAVA-41566 in our issue tracking system for the sake of correction. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hello,

we noticed an identical problem with the image https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg
An example of the html input file is below, the java code is the same:

<html lang="en">
<head>
<title>Images</title>
</head>
<body>
<div>
    <img src="https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg" alt="" />
</div>
</body>
</html>

Is this the same case as the PDFJAVA-41566 ?

Arjana Bivainiene

@arjana

Yes, the logged ticket is about the same issue. However, we have generated a separate ticket as PDFJAVA-41902 for your case. We have linked it as well with this forum thread. You will be notified as soon as the ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

hi,

Are there any progress for this problem? we also have this problem.

thanks.

@finansbank

We are afraid that the earlier logged tickets have not been yet resolved. However, we have recorded your concerns and will surely inform you as soon as we make some progress towards their resolution. Please spare us some time.

hi,

Aspose Pdf has a method as below, but “res” object has only getData function.
Is there any method for “set image data”, maybe we can set image data manually.

htmloptions.setCustomLoaderOfExternalResources(new LoadOptions.ResourceLoadingStrategy() {
    public LoadOptions.ResourceLoadingResult invoke(String resourceURI) {
        // Creating a clear template resource for replacing:
        LoadOptions.ResourceLoadingResult res = new LoadOptions.ResourceLoadingResult(new byte[] {});
        // Accessing the data (not clear what action is intended here)
        res.getData();               
    }
});

thanks.

@finansbank

We are afraid that the earlier logged ticket has still not been completely investigated. Your comments and concerns have been logged under it as well and as soon as we have some news about its resolution, we will share with you via this forum thread. We apologize for the inconvenience caused.