Library version: aspose.pdf-17.4.jar
Sample program:
import com.aspose.pdf.*;
public class Sample {
public static void main(String[] args) {
String strTempViewPathForHtml = "/share/Aspose_Trouble_Shooting/resources/RateQuote.html";
String strTempViewPathForPDF = "/share/Aspose_Trouble_Shooting/resources/RateQuote.pdf";
try {
/*
* System.setProperty("java.awt.headless", "true");
*/
License licenseWord = new License();
licenseWord.setLicense("Aspose.Total.Java.lic");
HtmlLoadOptions loadOptions = new HtmlLoadOptions();
loadOptions.getPageInfo().getMargin().setBottom(0);
loadOptions.getPageInfo().getMargin().setTop(0);
Document doc = new Document(strTempViewPathForHtml, new HtmlLoadOptions());
doc.save(strTempViewPathForPDF);
} catch (Exception e) {
e.printStackTrace();
}
}
}
OS Name: RHEL Linux 6.9
OS Version: 2.6.32-696.3.2.el6.x86_64
Apache Tomcat: 8.5.4
JVM Version: 1.8.0_131-b11
JVM Vendor: Oracle Corporation
The following exception is thrown:
java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at com.aspose.pdf.internal.p341.z5(Unknown Source)
at com.aspose.pdf.internal.p312.z5.m1(Unknown Source)
at com.aspose.pdf.internal.p296.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p312.z5.(Unknown Source)
at com.aspose.pdf.internal.p296.z3(Unknown Source)
at com.aspose.pdf.z89.m1(Unknown Source)
at com.aspose.pdf.z89.m1(Unknown Source)
at com.aspose.pdf.z89.m1(Unknown Source)
at com.aspose.pdf.z89.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 Sample.main(Sample.java:28)
As seen in the sample program, we added the System.setProperty(“java.awt.headless”, “true”) at one point, but the same results occurred.