I know this question is old, but these days I'd try puppeteer

const puppeteer = require("puppeteer");

async function printPDF() {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  await page.goto("http:///stackoverflow.com", {
    waitUntil: "networkidle0",
  });
  const pdf = await page.pdf({
    width: 1200,
    height: 1920,
    pageRanges: "1-2",
    path: "so.pdf",
  });

  await browser.close();
  return pdf;
}
printPDF();

Also see HTML to PDF with Node.js

Answer from Piotr Cierpich on Stack Overflow
🌐
npm
npmjs.com › package › html2canvas
html2canvas - npm
January 22, 2022 - Screenshots with JavaScript. Latest version: 1.4.1, last published: 4 years ago. Start using html2canvas in your project by running `npm i html2canvas`. There are 3164 other projects in the npm registry using html2canvas.
      » npm install html2canvas
    
Published   Jan 22, 2022
Version   1.4.1
Author   Niklas von Hertzen
🌐
html2canvas
html2canvas.hertzen.com › getting-started
Getting Started | html2canvas
You can install html2canvas through npm or download a built release.
Discussions

how to install html2canvas with npm
I want to use this in my react project, but do not know how to npm install it, anyone who know it ? More on github.com
🌐 github.com
1
September 21, 2017
html - A similar solution to html2canvas with nodejs - Stack Overflow
I'm using css, jquery and nodejs (with ejs and express) to create a website and I need to export a div with some text and some divs with a background-image as an image (jpg or png) but the best wou... More on stackoverflow.com
🌐 stackoverflow.com
node.js - Angular 2 - Import html2canvas - Stack Overflow
I have installed html2canvas on my angular 2 project using npm install html2canvas --save. If I now go to any file and write import * as html2canvas from 'html2canvas' it gives the error: Cannot ... More on stackoverflow.com
🌐 stackoverflow.com
How to use NPM package as normal javascript in HTML - Stack Overflow
I want to use html2canvas JS library in my application. I were able to use older versions of html2canvas in my application by directly loading html2canvas.js file in my HTML file. But newer versions are supported only through npm packages. More on stackoverflow.com
🌐 stackoverflow.com
🌐
npm
npmjs.com › package › html2canvas-pro
html2canvas-pro - npm
November 6, 2025 - Screenshots with JavaScript. Next generation!. Latest version: 1.5.13, last published: a month ago. Start using html2canvas-pro in your project by running `npm i html2canvas-pro`. There are 77 other projects in the npm registry using html2canvas-pro.
      » npm install html2canvas-pro
    
Published   Nov 06, 2025
Version   1.5.13
Author   yorickshan
🌐
html2canvas
html2canvas.net
HTML2Canvas: Capture Web Screenshots with JavaScript
You can install html2canvas via npm with the command npm install html2canvas.
🌐
Socket
socket.dev › npm › package › vue3-html2canvas
vue3-html2canvas - npm Package Security Analysis - Socket
November 27, 2023 - A html2canvas plugin for Vue 3. Version: 0.0.3 was published by krittapoj.lert. Start using Socket to analyze vue3-html2canvas and its dependencies to...
🌐
npm
npmjs.com › search
html2canvas - npm search
A combine usage with jsPDF and html2canvas, which translating html content to PDF file. npm · jsPDF · html2canvas · html2canvas-pro · johnnywang• 1.6.0 • 12 hours ago • 7 dependents • ISCpublished version 1.6.0, 12 hours ago7 dependents licensed under $ISC ·
🌐
Hertzen
html2canvas.hertzen.com
html2canvas - Screenshots with JavaScript
html2canvas(document.querySelector("#capture")).then(canvas => { document.body.appendChild(canvas) }); Try it outDocumentation · npm install --save html2canvas · yarn add html2canvas · html2canvas.jshtml2canvas.min.js · 45kb gzipped · Follow @niklasvh ·
Find elsewhere
🌐
GitHub
github.com › niklasvh › html2canvas › issues › 1224
how to install html2canvas with npm · Issue #1224 · niklasvh/html2canvas
September 21, 2017 - how to install html2canvas with npm#1224 · Copy link · xxxsf · opened · on Sep 21, 2017 · Issue body actions · I want to use this in my react project, but do not know how to npm install it, anyone who know it ? No one assigned · No labels · No labels ·
Published   Sep 21, 2017
🌐
npm
npmjs.com › package › @codewonders › html2canvas
codewonders/html2canvas
Easy package.json exports.. Latest version: 1.0.1, last published: 14 years ago. Start using package in your project by running `npm i package`. There are 278 other projects in the npm registry using package.
🌐
npm
npmjs.com › package › @xuannghia › html2canvas
@xuannghia/html2canvas - npm
Screenshots with JavaScript. Latest version: 1.4.2, last published: 2 years ago. Start using @xuannghia/html2canvas in your project by running `npm i @xuannghia/html2canvas`. There are no other projects in the npm registry using @xuannghia/html2canvas.
      » npm install @xuannghia/html2canvas
    
Published   Jan 17, 2024
Version   1.4.2
Author   Niklas von Hertzen
🌐
npm
npmjs.com › package › @types › html2canvas
@types/html2canvas - npm
July 6, 2021 - Stub TypeScript definitions entry for html2canvas, which provides its own types definitions. Latest version: 1.0.0, last published: 4 years ago. Start using @types/html2canvas in your project by running `npm i @types/html2canvas`. There are 41 other projects in the npm registry using @types/html2canvas.
      » npm install @types/html2canvas
    
Published   Jul 06, 2021
Version   1.0.0
🌐
jsDelivr
jsdelivr.com › package › npm › html2canvas-fixes
html2canvas-fixes CDN by jsDelivr - A CDN for npm and GitHub
July 17, 2017 - A free, fast, and reliable CDN for html2canvas-fixes. Screenshots with JavaScript
Published   Jul 14, 2017
🌐
Don't Panic Labs
dontpaniclabs.com › blog › post › 2023 › 08 › 31 › using-html2canvas
Using html2canvas
August 31, 2023 - JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
npm
npmjs.com › package › html2canvas-proxy
html2canvas-proxy - npm
July 6, 2018 - Cross-origin content proxy for html2canvas. Latest version: 1.0.1, last published: 7 years ago. Start using html2canvas-proxy in your project by running `npm i html2canvas-proxy`. There are 3 other projects in the npm registry using html2canvas-proxy.
      » npm install html2canvas-proxy
    
Published   Jul 06, 2018
Version   1.0.1
Author   Niklas von Hertzen
🌐
GitHub
github.com › niklasvh › html2canvas › releases
Releases · niklasvh/html2canvas
January 22, 2022 - niklasvh / html2canvas Public · Notifications · You must be signed in to change notification settings · Fork 4.9k · Star 31.7k · Releases · niklasvh/html2canvas · 22 Jan 16:43 · github-actions · v1.4.1 · 7c3269b · Compare · Filter · Loading · There was an error while loading.
Author   niklasvh