How to convert HTML to PDF

Hi,


I want to convert html to pdf in java, but I can’t get any satisfactory solution from anywhere, can any body give me how to use Aspose.pdf or any demo which convert html to pdf.

note: please give solution for java.

Thanks,
Sandeep

Hi Sandeep,


Thanks for your inquiry. You may convert HTML to PDF using Aspose.Pdf for Java. Please check following documentation link for the purpose. Hopefully it will help you to accomplish the task.


Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal Ahmad,


Thanks for your reply, I tried using solution which you have given me. Using that, pdf file is created but its blank,

Following is the HTML code which I am trying to convert into pdf,

Name Id Address
Kashif 007 US
Arshil 006 US
San 005 UK

Thanks,
Sandeep

Hi Sandeep,

Thanks for sharing the details.

I have tested the scenario using the latest release of [Aspose.Pdf for Java 9.3.1](http://www.aspose.com/community/files/72/java-components/aspose.pdf-for-jasync html and its results the aspirin scenario to generate create aspodel xml SVG helmet head>)
Please ensure that you are using a valid license to test the scenario. In case you do not have a license, you may consider requesting a 30-day temporary license to test the API without any limitations. For more information, please visit Get a temporary license

For your reference, I have also attached the resultant PDF generated on my end.

Java Code:

String basePath = "C:/pdftest/";
com.aspose.pdf.HtmlLoadOptions htmloptions = new com.aspose.pdf.HtmlLoadOptions(basePath);
htmloptions.setUseNewConversionEngine(true);
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(basePath + "html+page.html", htmloptions);
doc.save("c:/pdftest/Web+_output.pdf");