SampleFiles.zip (15.7 KB)
Aspose Team,
We use the Aspose PDF java package to convert html to pdf, and found out that some html files cannot be opened.
Following is the sample code and attached are two sample files.
The operating system is Ubuntu 20.04. Java version is 17. Aspose PDF java packages is 23.10.
import com.aspose.pdf.Document;
import com.aspose.pdf.HtmlLoadOptions;
import java.nio.file.Paths;
public class HtmlToPdf_26_27 {
public static void main(String[] args) throws Exception {
try {
new com.aspose.pdf.License().setLicense("/home/ubuntu/QmulusWorker/required/Aspose.Total.Java.lic");
String htmlFile = "/home/ubuntu/testdirs/html_to_pdf/REP.PC.00018622.0.htm";
String pdfFile = "/home/ubuntu/testdirs/html_to_pdf/REP.PC.00018622.0.htm_pdf_out.pdf";
HtmlLoadOptions options = new HtmlLoadOptions();
Document pdfDocument = new Document(htmlFile, options);
pdfDocument.save(Paths.get(pdfFile).toString());
}
catch(Exception ex) {
ex.printStackTrace();
}
}
The error for one file is as follows:
class com.aspose.pdf.internal.ms.System.l5if —> java.lang.NullPointerException
— End of inner exception stack trace —
com.aspose.pdf.internal.l34k.lh.lI(Unknown Source)
com.aspose.pdf.internal.l34k.lk.dispose(Unknown Source)
com.aspose.pdf.internal.html.dom.lk.navigate(Unknown Source)
com.aspose.pdf.internal.html.dom.lk.navigate(Unknown Source)
com.aspose.pdf.internal.html.lj.lI(Unknown Source)
com.aspose.pdf.internal.html.HTMLIFrameElement.getContentDocument(Unknown Source)
com.aspose.pdf.internal.l49f.l0k.lt(Unknown Source)
com.aspose.pdf.internal.l49l.lj.lj(Unknown Source)
com.aspose.pdf.internal.l49l.lj.lI(Unknown Source)
…
com.aspose.pdf.internal.l50k.lI.lI(Unknown Source)
com.aspose.pdf.internal.l42n.lt.lI(Unknown Source)
com.aspose.pdf.internal.l42n.lf.lj(Unknown Source)
com.aspose.pdf.internal.html.collections.lj.lj(Unknown Source)
com.aspose.pdf.internal.html.collections.lj.hasNext(Unknown Source)
com.aspose.pdf.internal.l50k.lI.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l0if.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l0if.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l1t.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l1t.lI(Unknown Source)
com.aspose.pdf.l7n.lf(Unknown Source)
com.aspose.pdf.l7n.lI(Unknown Source)
com.aspose.pdf.l7n.lI(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.ADocument.(Unknown Source)
com.aspose.pdf.Document.(Unknown Source)
xyang.tickets.aspose.HtmlToPdf.main(HtmlToPdf.java:27)
And the error for the other file is as follows:
class com.aspose.pdf.internal.l42f.l1if: A table-cell is spanning more rows than available in its parent element.
com.aspose.pdf.internal.l43h.lu.lf(Unknown Source)
com.aspose.pdf.internal.l43h.l1u$lj.lI(Unknown Source)
com.aspose.pdf.internal.l43h.l1u.lj(Unknown Source)
com.aspose.pdf.internal.l43h.l0t.l0u(Unknown Source)
com.aspose.pdf.internal.l42f.le.l0p(Unknown Source)
com.aspose.pdf.internal.l43h.l0t.l0p(Unknown Source)
com.aspose.pdf.internal.l43l.lf.lI(Unknown Source)
com.aspose.pdf.internal.l43l.lf.lI(Unknown Source)
…
com.aspose.pdf.internal.l50k.lI.lI(Unknown Source)
com.aspose.pdf.internal.l42n.lt.lI(Unknown Source)
com.aspose.pdf.internal.l42n.lf.lj(Unknown Source)
com.aspose.pdf.internal.html.collections.lj.lj(Unknown Source)
com.aspose.pdf.internal.html.collections.lj.hasNext(Unknown Source)
com.aspose.pdf.internal.l50k.lI.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l0if.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l0if.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l1t.lI(Unknown Source)
com.aspose.pdf.internal.html.rendering.l1t.lI(Unknown Source)
com.aspose.pdf.l7n.lf(Unknown Source)
com.aspose.pdf.l7n.lI(Unknown Source)
com.aspose.pdf.l7n.lI(Unknown Source)
com.aspose.pdf.ADocument.lI(Unknown Source)
com.aspose.pdf.ADocument.(Unknown Source)
com.aspose.pdf.Document.(Unknown Source)
xyang.tickets.aspose.HtmlToPdf.main(HtmlToPdf.java:27)