Convert HTML to PDF issue

When I convert a simple HTML to PDF it worked.


But if I covert this file.

Simple Transactional Email

Here is my code:

https://raw.githubusercontent.com/vanduc1102/JavaExampleMaven/master/src/main/java/my/example/aspose/ConvertHTMLtoPDF.java

I got the error :

java.lang.ClassCastException: com.aspose.pdf.internal.p64.z7 cannot be cast to com.aspose.pdf.internal.p65.z10

I googled the issue, and found no result.

Please help me.

Thanks

Hi Duc,

Thanks for your inquriy. I have tested the HTML to PDF conversion with shared document using Aspose.Pdf for Java 11.5.0 and unable to notice the reported issue. Please note you need to pass basepath if your HTML document is referring some external resources without absolute path.

com.aspose.pdf.HtmlLoadOptions htmloptions = new com.aspose.pdf.HtmlLoadOptions();

com.aspose.pdf.Document doc = new com.aspose.pdf.Document(myDir + "mail.html", htmloptions);

doc.save(myDir + "hele.pdf");

Please feel free to contact us for any further assistance.

Best Regards,

Thanks for the reply. My testing version is 10.6.1

I updated version of Aspose.Pdf Java 11.5.0

I got the message:


Exception in thread "main" class com.aspose.pdf.internal.ms.System.z9: At most 4 text fragments can be added in evaluation mode.
com.aspose.pdf.TextBuilder.m1(Unknown Source)
com.aspose.pdf.TextBuilder.appendText(Unknown Source)
com.aspose.pdf.z7.m1(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z17.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
com.aspose.pdf.internal.foundation.rendering.z30.accept(Unknown Source)
com.aspose.pdf.z7.m1(Unknown Source)
com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
com.aspose.pdf.z36.m1(Unknown Source)
com.aspose.pdf.ADocument.m1(Unknown Source)
com.aspose.pdf.ADocument.(Unknown Source)
com.aspose.pdf.Document.(Unknown Source)
my.example.aspose.ConvertHTMLtoPDF.main(ConvertHTMLtoPDF.java:27)
	at com.aspose.pdf.TextBuilder.m1(Unknown Source)
	at com.aspose.pdf.TextBuilder.appendText(Unknown Source)
	at com.aspose.pdf.z7.m1(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z17.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z11.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z14.accept(Unknown Source)
	at com.aspose.pdf.internal.foundation.rendering.z30.accept(Unknown Source)
	at com.aspose.pdf.z7.m1(Unknown Source)
	at com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
	at com.aspose.pdf.z36.m1(Unknown Source)
	at com.aspose.pdf.ADocument.m1(Unknown Source)
	at com.aspose.pdf.ADocument.(Unknown Source)
	at com.aspose.pdf.Document.(Unknown Source)
	at my.example.aspose.ConvertHTMLtoPDF.main(ConvertHTMLtoPDF.java:27)
Looked like it related with the license.

Thanks for your reply.

Hi Duc,

It appears that your license is expired and cannot be used with latest release. However before your upgrade your license subscription, you may consider requesting a 30 days temporary license by following instructions specified over Get a temporary license.