Registry / http-networking / html2pdf

html2pdf

JSON →
library0.1jsnpmunverified

A Node.js wrapper for wkhtmltopdf that converts HTML to PDF. Current version 0.0.11 is unmaintained since 2012 and only works with the legacy wkhtmltopdf binary (0.12.x series). Requires wkhtmltopdf to be installed separately on the system. Compared to modern alternatives like puppeteer or pdfmake, it offers no JS rendering support and is essentially deprecated. No release cadence; last commit was years ago. Not recommended for new projects.

npm install html2pdf
INSTALL
IMPORT
SIG · HTML2PDF
H
html2pdf
http-networkingjavascriptv0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const html2pdf = require('html2pdf');
import html2pdf from 'html2pdf';
ESM import fails because the package has no default export; only CJS require works.
html2pdf
const html2pdf = require('html2pdf');
import { html2pdf } from 'html2pdf';
No named export; the module exports a function directly.
type imports
not applicable (no TypeScript types)
import type Html2Pdf from 'html2pdf';
No types exist; trying to import types will fail.

Shows basic usage: converting an HTML string to PDF and piping to a file. Requires wkhtmltopdf binary installed.

const wkhtmltopdf = require('wkhtmltopdf'); const fs = require('fs'); // OR directly using html2pdf wrapper: const html2pdf = require('html2pdf'); // Convert HTML string to PDF const html = '<html><body><h1>Hello World</h1></body></html>'; html2pdf(html, { options: { pageSize: 'A4' } }).pipe(fs.createWriteStream('output.pdf')); console.log('PDF generated'); // Ensure wkhtmltopdf binary is installed and in PATH.
html2pdf --version
Debug
Known issues
deprecatedPackage is unmaintained since 2012 and wkhtmltopdf itself is in maintenance mode. Use puppeteer or other modern libraries.
fix
Migrate to puppeteer: npm install puppeteer. Then use: const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.setContent(html); await page.pdf({path: 'output.pdf'});
affects: all
breakingRequires wkhtmltopdf binary to be installed on the system; not a pure Node.js solution.
fix
Install wkhtmltopdf via system package manager (e.g., sudo apt-get install wkhtmltopdf) or download from https://wkhtmltopdf.org/downloads.html
affects: all
gotchaNo JavaScript rendering; complex CSS and JS-loaded content may not render correctly.
fix
Use a headless browser like puppeteer for JavaScript-heavy content.
affects: all
gotchawkhtmltopdf 0.12.6 deprecated and may be removed from distributions; in some Linux distros the package is being dropped.
fix
Switch to alternative PDF generation libraries (e.g., puppeteer, gotenberg, or weasyprint).
affects: >=0.12.6
Errors
Common errors & fixes
Error: spawn wkhtmltopdf ENOENT
wkhtmltopdf binary not installed or not in PATH.
fix
Install wkhtmltopdf: sudo apt-get install wkhtmltopdf (Linux) or download from https://wkhtmltopdf.org/downloads.html
Error: write EPIPE
wkhtmltopdf process exited prematurely; often due to invalid HTML or missing assets.
fix
Ensure HTML is well-formed and all referenced resources (CSS, images) are available or use base64 encoding.
TypeError: html2pdf is not a function
CommonJS require not used; trying to import as ES module.
fix
Use const html2pdf = require('html2pdf'); instead of import.
Error: Module 'wkhtmltopdf' not found
Missing dependency or wrong import path.
fix
Install wkhtmltopdf package: npm install wkhtmltopdf. Alternatively, the html2pdf package bundles wkhtmltopdf as a dependency, but it may not be installed correctly.
Upgrade
Version history
0.1latest on npm
Audit
Dependencies
wkhtmltopdfrequiredThe package is a thin wrapper that spawns wkhtmltopdf binary; it will not work without it.
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
2
Resources
html2pdf — npm install html2pdf · libregistry