Hi Team,
Can you please provide some sample code to convert HTML to PDF document using Aspose.html.
PFA sample html file.sample3.zip (1.1 KB)
Regards,
Sushant
Hi Team,
Can you please provide some sample code to convert HTML to PDF document using Aspose.html.
PFA sample html file.sample3.zip (1.1 KB)
Regards,
Sushant
Thanks for contacting support.
Please visit the following link for required information on Converting HTML files to PDF format.
Thanks
Could you please send me the sample code for this in JAVA. I did not find anything related to HTML to PDF in Aspose.HTML in JAVA. so please share the sample code in java. Also please include Header Footer code in the sample code also.
Thanks,
Sushant
Thanks for sharing the details.
The following code snippet offers the feature to convert HTML file to PDF format using Aspose.Html for Java but I am afraid currently the API is having some issues. I am further investigating this problem with product team and will get back to you soon. We are sorry for this inconvenience.
[Java]
// File name for resultant PDF file
String Resultant_output = "c:/pdftest/simple-any-page.pdf";
// create PdfRendering Options object
com.aspose.html.rendering.pdf.PdfRenderingOptions pdf_options = new com.aspose.html.rendering.pdf.PdfRenderingOptions();
// The PageSetup also provides different properties i.e. FirstPage, LastPage,
// LeftPage, RightPage and they are used to setup (PageSize, Margin) for every page.
// In most cases, usage of setup any page is enough, but in some complicated cases,
// you may need to fine tune page settings. It can be done either by CSS styles or by using rendering options.
// the size for drawing is in pixels
pdf_options.getPageSetup().setAnyPage(new com.aspose.html.drawing.Page(new com.aspose.html.drawing.Size(400, 100)));
// instantiate PdfDevice object while passing PdfRenderingOptions and resultant file path as arguments
try{
com.aspose.html.rendering.pdf.PdfDevice pdf_device = new com.aspose.html.rendering.pdf.PdfDevice(pdf_options, Resultant_output);
// Create HtmlRenderer object
com.aspose.html.rendering.HtmlRenderer renderer = new com.aspose.html.rendering.HtmlRenderer();
// Create HtmlDocument instance while passing path of already created HTML file
com.aspose.html.HTMLDocument html_document = new com.aspose.html.HTMLDocument("c:/pdftest/Input.html");
// render the output using HtmlRenderer
renderer.render(pdf_device, html_document);
}
finally
{}