We are encountering a problem.
We use something like the following to create a PDF document from a HTML text:
private Document createPdfDocumentFromHtml(String html) {
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.getPageInfo().setMargin(new MarginInfo(0, 0, 0, 0));
return new Document(StreamUtils.toInputStreamUtf8(html), htmlLoadOptions);
}
The problem that we have is that when we use images that are bigger than 50kb it takes 10 minutes or even longer to prepare the pdf. That’s way to long.
Is there a way how we can speed up that process? Are there any updated libraries that we can use?
The usecase that we have is to put a company logo on a letterhead in html and then for the print-out we want to convert this to a pdf.
The conversion HTML to PDF with an ususal image inside that is base64 encoded
What are possible solutions to this problem?
Any help is much appreciated.
@StevenBukenberger
Can you please make sure that you are using 21.5 version of the API as performance of the API is much improved in the latest version. In case issue is still persisting, please share your sample HTML file with us in .zip format. We will test the scenario in our environment and address it accordingly.
@asad.ali
We use the version 20.5:jdk17 (about 1 year old). I have tried to use the latest version, but it works in the same (slowly) way. Attached is an example html_for_convert.zip
html_for_convert.zip (67.0 KB)
@StevenBukenberger
We have tested the scenario in our environment while using 21.5v of the API. We did not notice any issue as the PDF was generated in less than 10 seconds. Could you please try to use 21.5 version? Also, please try to increase the Java Heap Size as well. In case issue still happens, please share your complete environment details i.e. OS Name and Version, Application Type, etc. We will further proceed to assist you accordingly.
@asad.ali
Thanks for your reply.
We have changed the version to 21.5 but it didn’t help. You use an old version of Java (7 and 8). We use Java 15.
We have converted this service to Java 8 and it started to work quick.
Can you please check Java15?
@StevenBukenberger
An investigation ticket as PDFJAVA-40596 has been logged in our issue tracking system for the analysis against this behavior of the API under Java 15. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.
We are sorry for the inconvenience.