Free Support Forum - aspose.com

Convert Html to Pdf in Java

I’m currently evaluating the Java aspose lirary to generate pdf using html web page.



I’m following a C# tutorial since i don’t find one written for Java. My problem is to be able to set the pdf.HtmlInfo.ImgUrl property.



In my case HtmlInfo is an object of type aspose.pdf.e.Aac with some properties a, b, c and so on but no setImgUrl method.



Could you please tell me what’s wrong ?



regards.

Hi Fabrice,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.Pdf for Java.

Well, at the moment Aspose.Pdf for Java supports conversion of HTML string to PDF using text.setIsHtmlTagSupported(Boolean) method. You can use the following sample code to convert HTML string to PDF file using Aspose.Pdf for Java. Please try it and in case you face any issue, please feel free to contact support.

//Instantiate Pdf object by calling its empty constructor

Pdf pdf1 = new Pdf();

// create section object

Section sec1 = pdf1.getSections().add();

// create a Text object with sample text string with some HTML Tags

Text html_text = new Text(" Bold Text and simple Italic Text");

// set the value of IsHtmlTagSupported to true so that HTML tags are rendered accordingly

// rather than being displayed as static text

html_text.setIsHtmlTagSupported(true);

// add the text paragraph to paragraphs collection of section object

sec1.getParagraphs().add(html_text);

// save the resultant PDF

pdf1.save("OutputPDF.pdf");

Sorry for the inconvenience,