Difficulty using Converter class to convert Html/Mhtml file to PDf

Hello, the code example in the aspose html github repository does not work (https://github.com/aspose-html/Aspose.HTML-for-Java/blob/master/src/test/java/com/aspose/html/examples/Examples_Java_Conversion_HtmlToPdf_1.java) I am trying to convert an incoming HMTL and MHTML file to PDF and am using Aspose-HTML 23.8 and Aspose-PDF 23.8. My method will take in an input stream, but it does not seem like the html library supports conversions like the other ones do. Can someone please help me?


Would you please share your sample HTML/MHTML with us in .zip format along with the details of the issues that you are facing at your end? We will test the scenario in our environment and address it accordingly.

Sure, thank you for getting back to me. Currently, we are trying to use the Converter.convertHtml method as described in your documentation, but are having issues saving the converted PDF content to a byteArrayOutputStream. We also tried saving the converted PDF to a file, with the code that I linked to from the aspose Github examples (more specifically this: Convert HTML to PDF Using Java), but that was also unsuccessful. If you could please provide direction on Aspose HTML’s support to convert html/mhtml files to PDF and save them to a ByteArrayOutputStream (or even just a temp file), that would be appreciated. Thank you. Attached is the test file: sample_light.zip (258 Bytes)

The exception we are continually getting is from Converter.convertHtml from something related to screenDevices. We are unsure as of how to proceed. While we can do File IO, using streams is preferred greatly in our use case.

It looks like it is throwing the exception when trying to getScreenDevices. Is there a way to circumvent this?


We have opened the following new ticket(s) in our internal issue tracking system for the investigation against this case.

Issue ID(s): HTMLJAVA-1601

We will 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.