We are unable to convert HTML file to PDF on some machines. We are using Aspose PDF version 19.10.
Following is the code sample we are using:
public class AsposePOC2 {
// Absolute path to html file path
private static final String INPUT_FILE_PATH = “smail.html”;
// Absolute path to where output pdf file needs to be created
private static final String OUTPUT_FILE_PATH = “smail.pdf”;
// Absolute path to license path
private static final String LICENSE_FILE_PATH = “Aspose.Total.Java.lic”;
public static void start() throws Exception {
Path inputPath = Paths.get(INPUT_FILE_PATH);
if(Files.notExists(inputPath)){
throw new Exception("Failed to access input file");
}
Path licensePath = Paths.get(LICENSE_FILE_PATH);
if(Files.notExists(licensePath)){
throw new Exception("Failed to access license file");
}
Path outputPath = Paths.get(OUTPUT_FILE_PATH);
Files.deleteIfExists(outputPath);
try(InputStream inputStream = Files.newInputStream(inputPath);
OutputStream outputStream = Files.newOutputStream(outputPath)){
HtmlLoadOptions options = new HtmlLoadOptions();
License license = new License();
license.setLicense(Files.newInputStream(licensePath));
Document pdfDocument = new Document(inputStream, options);
pdfDocument.save(outputStream);
}catch (Exception e){
e.printStackTrace();
}
System.out.println("DONE!!");
}
}
We are getting NullPointerException with following stacktrace:
at com.aspose.pdf.internal.l29if.le.lt(Unknown Source)
at com.aspose.pdf.internal.l29if.le.lh(Unknown Source)
at com.aspose.pdf.internal.l29if.le.le(Unknown Source)
at com.aspose.pdf.internal.l29if.le.lf(Unknown Source)
at com.aspose.pdf.internal.l44l.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l44l.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l44l.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.lc.lc(Unknown Source)
at com.aspose.pdf.internal.l42l.lt.l1n(Unknown Source)
at com.aspose.pdf.internal.l42l.l0l.l6f(Unknown Source)
at com.aspose.pdf.internal.l42l.l0l.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l0l.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.lk.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.lk.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l1l.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l3n.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l3n.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l3n.lj(Unknown Source)
at com.aspose.pdf.internal.l42l.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l3n.lI(Unknown Source)
at com.aspose.pdf.internal.l42l.l4if.l2n(Unknown Source)
at com.aspose.pdf.internal.l38t.lb.lf(Unknown Source)
at com.aspose.pdf.internal.l39y.lk.l0p(Unknown Source)
at com.aspose.pdf.internal.l39l.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l39l.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l39l.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l38if.lj.lI(Unknown Source)
at com.aspose.pdf.internal.l38l.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l46f.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l38n.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l38n.lf.lj(Unknown Source)
at com.aspose.pdf.internal.html.collections.lf.lj(Unknown Source)
at com.aspose.pdf.internal.html.collections.lf.hasNext(Unknown Source)
at com.aspose.pdf.internal.l46f.lI.lI(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.HtmlRenderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.internal.html.rendering.Renderer.render(Unknown Source)
at com.aspose.pdf.l6u.lI(Unknown Source)
at com.aspose.pdf.l6u.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.ADocument.(Unknown Source)
at com.aspose.pdf.Document.(Unknown Source)
at com.example.demo.AsposePOC.start(AsposePOC.java:62)
at com.example.demo.DemoApplication.main(DemoApplication.java:12)