We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Html2pdf

Hi,How Can I convet Html document to pdf In java?
regards

Hi,

You can use the bindHTML method. Please try the following code:

try {

Pdf pdf = new Pdf();
File htmlFile = new File("c:/testing.html");
try {
FileInputStream fin = new FileInputStream(htmlFile);
FileOutputStream fout = new FileOutputStream(new File("c:/testing.pdf"));
pdf.bindHTML(fin, htmlFile.toURL());
pdf.save(fout);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (MalformedURLException ex) {
ex.printStackTrace();
}

} catch (AsposeBaseException ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
System.out.println(ex.getErrorCode());
}

Thanks.