Free Support Forum -

Need help to convert html to PDF

I got some issues converting html to pdf and they failed. I attach some files here. (35.5 KB)

The other question is want to ask is that it is generally slow to convert html to pdf. Is there any approach to improve the performance? Does Aspose code fetch any content through internet if there is a link in the html file?



The Aspose.HTML does not fetch any content from the internet. However, could you please share the sample code snippet that you are using to convert the attached files? We will test the scenario in our environment and address it accordingly.

We use something like this.

pdfSaveOptions = new PdfSaveOptions();
if (StringUtils.startsWithIgnoreCase(FilenameUtils.getExtension(inputFile.getFilePath()), "M") || StringUtils.startsWithIgnoreCase(inputFile.getFileType(), "M") ) {
                Converter.convertMHTML(inputFile.getFilePath(), pdfSaveOptions, responseFilePath);
} else {
                Converter.convertHTML(inputFile.getFilePath(), pdfSaveOptions, responseFilePath);

@asad.ali i re-run the failed html files and most of then were successfully converted to pdf except this one here. (1005.2 KB)

The interesting thing is that the fails appeared to be related to multithreading processes.
I am planning to use rerun method unless you can find something wrong for me.

On the other hand, I do have an issue with html performance hit. One attached here document took 10 minutes to convert. I attached it here for you and maybe you can find out a fix for us. I have no idea why it took so long since this is a simple html page document. (5.4 KB)



We were able to notice java.lang.StackOverflowError Exception with the above file while testing the scenario with Aspose.HTML for Java 20.12. Therefore, have logged an issue as HTMLJAVA-736 in our issue tracking system for the sake of correction.

Furthermore, we were also able to notice the delay in conversion process in case of the second HTML file that you shared. A ticket as HTMLJAVA-737 has been logged for this case so that we can investigate and check how performance can be improved for conversion process.

We will look into details of both tickets and keep you posted with the status of their correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

thank you @asad.ali.

I wonder why the delay is extensive. is it trying to connect to internet or doing some checking and could not get through?

Thank you so much for taking care of the issues.

I know you guys always did great job supporting us and I don’t know if this matters and changes anything as we have purchased the license. If this info can expediate the process, please let me know.



The API does not try to connect to the internet for conversion unless there is some resource loading from an URL in the HTML e.g. image. However, we will further investigate the reasons behind this behavior of the API and let you know once additional updates are available. We have also recorded your concerns and will consider them during the investigation of the logged ticket. Please give us some time.

We apologize for the inconvenience.

Thanks @asad.ali I will let your engineers to work on that.

Just want to confirm one thing. If an html page has the img, it will try loading the jpg from the source, in this case, it is

is that correct? what if the resource is not reachable or deleted or blocked due to security rules?

Note i removed the <> tag from the html below in order for you to see the html content. otherwise you will see the empty image with “ivari” text like the bottom of the message.

img width=117 height=50 id="_x0000_i1025"
style=‘display:block’ alt=ivari



Yes, that is correct. The API will try to load the JPG from the source and the delay in conversion is happening as the source is not available or blocked. When we removed the image source from HTML, the conversion speed increased and output PDF was generated in seconds.

that’s good to know @asad.ali, thank you. If the remote resource is not available, would it make sense to have a configurable setting like time to wait so it does not have to wait too long?

Do you have any recommendation how we can work around this type of problems?



This is something that we need to implement in the API yet. For the sake of implementation, we have logged a feature request as HTMLJAVA-738 in our issue tracking system. We will surely inform you as soon as the feature is available. Please give us some time.

We apologize for the inconvenience.

I want to follow up this issue, @asad.ali.

Sometimes hyper link within a html file does not exist anymore because the remote site has been deleted. When converting html to pdf document seems taking a bit longer, like 2 minutes for one page html page. I know we’re ok to just ignore those remote resources, but how do i do to shorten the conversion time? Is there any parameter to pass to html to pdf conversion and dictate the program NOT TRYING to retrieve any remote resources? We’re running the conversion in a server which does not have internet connection anyways.

I can set up a proxy server for http request, how do I tell the program to use the proxy or can we change http request timeout setting? Either one of these should allow us to improve the performance.

Thanks for your help.


We regret to inform you that the ticket HTMLJAVA-738 has not been yet fully investigated. Please note that we will surely investigate and resolve the ticket however, it will be resolved on a first come first serve basis. We will certainly inform you as soon as some significant progress is made towards its resolution. Please give us some time.

We apologize for the inconvenience being faced.