Some test text!

Loading...
Guides
Web/HTML to PDF

Convert HTML to PDF in Node.js

HTML2PDF Module is an optional add-on utility which can be used with PDFTron SDK to convert an HTML file to a PDF document without any external third party dependencies.

You can find more details about how to install HTML2PDF Module here

Requires the HTML2PDF module add-on.
async function main() {
  // Start with a PDFDoc (the conversion destination)
  const doc = await PDFNet.PDFDoc.create();
  const converter = await PDFNet.HTML2PDF.create();

  // add from HTML String data
  converter.insertFromHtmlString(htmlString);

  // add from a web page location
  converter.insertFromUrl(webPageLocation);

  // apply conversion
  await converter.convert(doc);
}
PDFNet.runWithCleanup(main);

Convert HTML to PDF
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.

Get the answers you need: Support

Upcoming Webinar: SDK Features Preview and Live Run-Through | July 14, 2022 at 11 am PT

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use