PDF document not created when converting from HTML if it contains images

Hello,

Recently, we started experiencing a strange problem.
We use Aspose java to convert html documents to PDF in a bigger web application that is deployed on the Tomcat web container.
Everything was working more or less fine until recently when conversion stopped working with any html documents if there is any image within. Our htmls are constructed dynamically, and image data is received dynamically as well. Images are referenced as base64 encrypted data within an html, e. g. <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABHgA …

If I copy the same html and convert it in a standalone application using the same version version of aspose and other parameters, it is successfully saved to PDF.

If I specify image src using a path <img src=“https://some_image.png” … within our web application, it works as well. But if the image src is in the format <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABHgA , the code stops when creating the output document:

Document document = new Document(targetStream, options);

No exception is thrown, the code never ends.
We tried to look into program internals and we see that the thread is stopped at Object.wait(). I attached the thread dump to the issue. Maybe you could provide some information about what’s going on and what we could also check, what could be causing such a behavior?

thread_waiting.png (100.7 KB)

The behavior is observed using Aspose 21.8 and 23.6. The attachedd thread dump is of version 23.6.
Java: 17

Thank you

Arjana Bivainiene
thread_waiting.png (101 KB)

@arjana

Could you please share a sample HTML in .zip format for our reference as well? We will test the scenario in our environment and address it accordingly.

Here is the sample: samples.zip (1.6 KB)

There are two htmls inside with different img src values for comparison. no_pdf.html is the one that makes the thread stop, and always_works.html is not.

As I mentioned, I used it in a small isolated Java application, and it is converted to PDF without problems. And it used to work in a bigger web application for quite a long period of time.
During the period we noticed that the conversion does not work anymore, we updated some internal libraries due to certain external changes we cannot control, and other parts of our application do not work without updates.
The Aspose library has no dependencies on its own, and none of other changes seem to be related to the PDF functionality. But it started to stop at the new Document(…), and the thread is waiting for something that we cannot understand.

I recreated a separate web application using the spring boot, here is the complete application: aspose-img-wait2.zip (77.6 KB)
It recreates the same situation without any dependencies, so it’s not changes in our internal dependencies that cause the problem.

If run without changes, it will start the server on the 8080 port, and two requests can be used:
http://localhost:8080/pdf?embedImage=false will use the file src/main/resources/html_with_linked_Image.html and the pdf will be created
http://localhost:8080/pdf?embedImage=true will use the file src/main/resources/html_with_embedded_image.html and the program will not finish processing request, it will be stuck at new Document(…)

Now I can see two threads waiting: thread1.png (98.1 KB)
thread2.png (82.1 KB)

@arjana

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-42986

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.