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

Free Support Forum - aspose.com

Loading html document with external css

When loading css files from an external https resource that is using a self-signed ssl certificate the process hangs for roughly two minutes for each css file referenced in the html doc.

Using LoadOptions ResourceLoadingStrategy we can get around the certificate error, however; we still have to wait for each file to timeout.

Is there a way to reduce the timeout on the loading of the css file or any other suggestions you can provide?

@verinti

Would you please share complete code snippet that you are using for conversion. We will test it in our environment and address the issue accordingly.

Sample code is below. The main issue is when the stylesheet link is on a server using a self signed ssl certificate. The css is not applied during the conversion and it will take roughly 2 minutes to complete. Looks like the request to access the style sheet is not handling the certificate exception.

Document doc = new Document();
Page page = doc.getPages().add();

String CSS = "<link rel=\"stylesheet\" href=\"https://localhost:8080/ClientResources/cr/202009180301/-/webclient/themes/default/theme.css\">";

String content = "<div class=\"xui-body-content\">";
content += "<div>Public Information</div>";
content += "</div>";

HtmlFragment html = new HtmlFragment(CSS + content);
html.setBreakWords(false);
page.getParagraphs().add(html);
doc.save("example.pdf");

@verinti

Would you please share a working link of external CSS so that we can test the scenario with it and try to observe the delay. With recently shared code snippet, the API took 12 seconds in our environment to generate PDF file as the CSS file link was invalid at our side.

I don’t have an external facing site that I can share for testing. The easiest thing is to use nginx or apache to host a css file and generate a self-signed certificate using openssl to use with which ever host you are most comfortable with setting up.

For example: openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt

Is there a way to include a timeout on the web requests? Is there any logging we can turn on to help gather more information?

Also note that an invalid url seems to fail right away.

@verinti

Thanks for providing further details.

We regret to share that there is no way to set timeout or reduce it in the API at the moment. However, we have logged an investigation ticket as PDFJAVA-39799 in our issue tracking system to further analyse your requirements. We will look into scenario detail and will keep you informed about resolution status of the ticket. We will let you know in case we require any further information from your side. Please be patient and give us some time.

We are sorry for the inconvenience.

Please note we are using the java version of the library.

Thank you

@verinti

We have updated the ticket information accordingly.

Is there a way to share with you a link to a css file that also shows the slowness in loading that we cant share on the public support sight?

@verinti

Sure, you can send the URL in a private message by clicking over username and pressing Blue Message Button.