Skip to content
On this page

Render from HTML as source

Step ❶ : HTML content

You can write your HTML content as a string or extract it from a file.

const HTML = `<!DOCTYPE html>
    <h1>This a heading</h1>
    <p>This a paragraph</p>

Step ❷ : Request

setContent.html property has to be base64 encoded.

const encodedHTML = new Buffer.from(html, 'utf8').toString('base64')

const options = {
  method: 'POST',
  url: '',
  headers: {
    'Authorization': 'Bearer <YOUR API KEY>',
    'Content-Type': 'application/json'
  encoding: null, // necessary to receive binary data
  body: JSON.stringify({
    page: {
      pdf: {
        printBackground: true
      setContent: {
        html: encodedHTML
const request = require('request');

request(options, function (error, response) {
  if (error) throw new Error(error);

All rights reserved