@koukitsuko/html2pdf.js
v0.11.0
Published
Client-side HTML-to-PDF rendering using pure JS
Maintainers
Readme
@koukitsuko/html2pdf.js
A fork of html2pdf.js with modern build tooling and improved HTML rendering.
Changes from the original
This fork makes the following improvements to the original html2pdf.js:
- Replaces
html2canvaswithhtml2canvas-profor improved HTML rendering - Uses modern build tooling to provide ESM, CommonJS, and UMD builds
- Simplified package structure for easier use in modern JavaScript environments
Installation
# Using npm
npm install @koukitsuko/html2pdf.js
# Using pnpm
pnpm add @koukitsuko/html2pdf.jsUsage Examples
ESM Import (Recommended)
import html2pdf from '@koukitsuko/html2pdf.js';
// Generate PDF from element
const element = document.getElementById('element-to-print');
html2pdf().from(element).save('my-pdf.pdf');CommonJS
const html2pdf = require('@koukitsuko/html2pdf.js');
// Generate PDF from element
const element = document.getElementById('element-to-print');
html2pdf().from(element).save('my-pdf.pdf');Documentation
For detailed API documentation, options, and advanced usage, please refer to the original html2pdf.js documentation.
Development
Build Commands
# Install dependencies
pnpm install
# Build development version
pnpm run dev
# Build production version
pnpm run buildBuilding and Contributing
- Clone the repository
- Install dependencies with
pnpm install - Make changes to files in the
srcdirectory - Build with
pnpm run build - Test your changes
- Submit a pull request
Credits
This project is a fork of html2pdf.js by Erik Koopmans.
License
Copyright (c) 2017-2019 Erik Koopmans <http://www.erik-koopmans.com/>
