Converting HTML into PDF ( Java version )

We are trying to evalualte this product whether it meets our requirements. We use JAVA here. I need some example for converting HTML ( preferably with CSS, images, hyperlinks, etc..) into PDF.

thanks alot

Bontu A

Hi Bontu,


Thanks for your inquiry. We are looking into your request and will get back to you soon.

Best Regards,

Hi Bontu,


Thanks for your patience. I’m afraid the requested feature is not supported in Java version at the moment. However, I’ve logged a request as PDFNEWJAVA-33667 in our issue tracking system for its implementation. We will update you via this forum thread as soon as it gets available.

Sorry for the inconvenience faced.

Best Regards,

Hi Bontu,

Thanks for your patience. We have good news for you, your requested feature has been implemented in Aspose.Pdf for Java 4.3.0. Please download latest version and try following code snippet for the purpose.

StringBuffer sb = new StringBuffer(1024);

BufferedReader reader = new BufferedReader(new FileReader(
myDir + "htmltest123.html"));
char[] chars = new char[1024];

while((reader.read(chars)) > -1){
sb.append(String.valueOf(chars));
}

reader.close();

//Instantiate Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();

//Create a new section in the Pdf object
Section sec1 = pdf1.getSections().add();

//Create a new text paragraph and pass the text to its constructor as argument
Text text1 = new Text(sec1, sb.toString());

// use the following method to render the HTML tags accordingly
text1.isHtmlTagSupported(true);

// add text paragraph to paragraphs collection of section object
sec1.getParagraphs().add(text1);

// save the resultant PDF document
pdf1.save(myDir + "HTMLtoPDF_java.pdf");

Please feel free to contact us for any further assistance.

Best Regards,