Convert HTML to PDF on Server/Desktop: Sample Code in Python, Java, C#, JavaScript, PHP, and C++
HTML2PDF Module is an optional add-on utility which can be used with Apryse SDK to convert an HTML file to a PDF document without any external third party dependencies. Samples offered in Python, Java, C#, JavaScript, PHP, Ruby, C++, Objective C, Go, VB; for Mac, Linux and Windows.
To use this code, you'll need to
Warning
Requires the HTML2PDF module add-on. All files in the Lib folder of the archive must be present for the module to work as expected.
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();
HTML2PDF converter = new HTML2PDF();
// add from HTML String data
converter.InsertFromHtmlString(htmlString);
// add from a web page location
converter.InsertFromURL(webPageLocation);
// apply conversion
converter.Convert(doc);// Start with a PDFDoc (the conversion destination)
PDFDoc doc;
HTML2PDF converter;
// add from HTML String data
converter.InsertFromHtmlString(htmlString);
// add from a web page location
converter.InsertFromURL(webPageLocation);
// apply conversion
converter.Convert(doc);Convert HTML to PDF - Full Sample Code Full sample code for directly converting HTML pages to PDF by using 'pdftron.PDF.HTML2PDF'. The HTML2PDF converter supports HTML conversion from a string or URL and offers many options to control page size and formatting. Samples available in Python, C# (.Net), C++, Go, Java, Node.js (JavaScript), PHP, Ruby, VB.
Last updated
Was this helpful?