Hi Sid,
com.aspose.pdf.Document
document = new com.aspose.pdf.Document(“C:\pdftest\test.html”, new
com.aspose.pdf.HtmlLoadOptions());<o:p></o:p>
try {
document.save("C:\\pdftest\\test.pdf");
} finally {
document.close();
}
extractText("C:\\pdftest\\test.pdf");
protected static void extractText(String input) {
com.aspose.pdf.Document document = new com.aspose.pdf.Document(input);
try {
TextAbsorber absorber = new TextAbsorber();
document.getPages().accept(absorber);
System.out.println(absorber.getText());
} finally {
document.close();
}
}
Hi Sid,
exptest.convertDocument();
I’m not sure why you can’t locate the commons-io 2.5 jar but it should be available in the central repository:
http://repo1.maven.org/maven2/commons-io/commons-io/2.5/
The comparison failure is probably due to line separator differences. I’m running these tests on Mac OS (10.12.4) and Ubuntu Linux (14.04 server).
Please make sure you are executing the test as written with the @BeforeClass method in place:
@BeforeClass
public static void initLicense() throws Exception {
new License().setLicense("/tmp/Aspose.Total.Java.lic");
System.setProperty(“java.awt.headless”, “true”);
}
The system property (java.awt.headless) must be true to emulate how the code would run on a server environment without a UI running.
Including this thread for reference:
Hi Sid,
snewby:
It looks like this may be a regression bug which was fixed in PDFNEWJAVA-34641 via version 10.3.0.
Thanks for the update
Hi Andrew,sdxmessaging:
I have a similar problem with 17.3, 17.4 (cannot use 17.5 as maintenance expired at end of May.Note that 17.2 works OK, so regression introduced in 17.3 and continued to at least 17.4.
We have replaced Itext with aspose-pdf and were running the 17.3 version. Once completed we ran into the HeadlessException when generating PDFs with HTML. Based on the comments we moved back to 17.2 and are able to move forward at this time. I hope this issue is high on the list to correct as it impacts our ability to use newer versions of aspose-pdf. Especially since this seems to be a regression of a fix from 10.3.
Throughout our project to remove Itext and replace it with aspose-pdf we ran into a number if issues where Itext handled things fine and the aspose-pdf implementation resulted in exceptions.
@SciQuest_Development,
We have logged this information under the same linked ticket ID PDFJAVA-36737. We will let you know once it is fixed.
We recommend our clients to post each their problem in the form of a use case, including source documents and code snippets along with the details of each problem. If you have any other problem which has not been reported yet, then share details with us. We will investigate and let you know about our findings.
Best Regards,
Imran Rafique