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

Free Support Forum - aspose.com

Convert PDF to HTML in Java - Unable to convert with all images/resources embedded in single file

Hello there, while i got the logic working for word, for pdf i am unable to acheive the same goal, which is to have a single html file contain all images/resources of the parent file. I am using the code snippets mentioned here:https://docs.aspose.com/display/pdfjava/Convert+PDF+to+HTML+format
keep getting the exception as shown in stack trace:

------------------stack trace-----------------
INFO: path to save pdf resources: dynamic_resources/85ffa91b-c98a-4c41-a62d-184f4ff7ed5c
Exception in thread “main” class com.aspose.pdf.exceptions.PdfException: Inconsistent saving options detected : ‘CustomStrategyOfCssUrlCreation’,‘CustomCssSavingStrategy’,‘CustomResourceSavingStrategy’ may not be null when requested saving to stream!
com.aspose.pdf.HtmlSaveOptions.lt(Unknown Source)
com.aspose.pdf.HtmlSaveOptions.lI(Unknown Source)
com.aspose.pdf.l7if.lI(Unknown Source)
com.aspose.pdf.ADocument.lj(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.Document.lI(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)
at com.aspose.pdf.HtmlSaveOptions.lt(Unknown Source)
at com.aspose.pdf.HtmlSaveOptions.lI(Unknown Source)
at com.aspose.pdf.l7if.lI(Unknown Source)
at com.aspose.pdf.ADocument.lj(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.Document.lI(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)
at com.aq.aspose.Main.convertPDFToHTML(Main.java:52)
at com.aq.aspose.Main.doWork(Main.java:38)
at com.aq.aspose.Main.main(Main.java:274)

Process finished with exit code 1

PDF I am trying to convert
mss.pdf (336.9 KB)

-----------------------Aspose PDF for Java library-----------


forgot to mention that a licensed version is being used


Thanks for contacting support.

We have tested the scenario using Aspose.PDF for Java 19.12 with PDF to HTML - Single HTML with All Resources Embedded example from API documentation and were unable to notice any issue. The PDF document was converted without throwing any exception. For your kind reference, an output HTML is also attached.

Single_output.zip (723.1 KB)

Would you kindly try using latest version of the API and in case you still face any issue, please share a sample console application that is able to replicate the issue along with the environment details where you are using the API e.g. OS Name and Version. We will again test the scenario in our environment and address it accordingly.

please close the ticket as i am able to do this outside my tomcat server, in a standalone java program

1 Like