Blog

Back to blog posts

Convert HTML to PDF with nodejs / javascript

Published Sep 02, 2018

Intro

Here at Api2Pdf, we are proud to announce a new client library for nodejs! Our node library makes it easy to convert HTML to PDF, URL to PDF, Word to PDF, and Merge PDFs together. We support a number of endpoints such as wkhtmltopdf, Headless Chrome, and LibreOffice.

View the documentation for our Nodejs client library here: https://github.com/Api2Pdf/api2pdf.node#readme

Api2Pdf is an HTML to PDF API that runs on AWS Lambda, allowing it scale to millions of requests with no rate limits or file size limits.

Convert HTML to PDF with Javascript

The quick start guide is to first grab an API key by signing up at https://portal.api2pdf.com.

Install your package by entering:

npm install –save api2pdf

Initialize the client in your code with:

var Api2Pdf = require('api2pdf');   
var a2pClient = new Api2Pdf('YOUR-API-KEY');
a2pClient.wkhtmltopdfFromHtml('<p>Hello, World</p>').then(function(result) {
    console.log(result);
});

View all the other options we have available, such as Word to PDF with Javascript, etc, etc on our documentation.