Convert HTML to PDF using Chrome (Puppeteer)
Export PDF from Websites or HTML Files.
Alterative of wkhtmltopdf but pptrhtmltopdf uses Headless Chrome.
- Add cover page 🆗
- Add backcover page 🆗
- Generate TOC page 🆗
- Support multi HTML 🆗
- Support local HTML 🆗
- Support Website 🆗
Output PDF Example: examples/output-examples.pdf
npm install pptrhtmltopdf
NAME
pptrhtmltopdf [OPTIONS] [FILE or URL]...
Convert HTML to PDF using Chrome (Puppeteer)
DESCRIPTION
--output=[FILE] Save PDF to [FILE]
--cover=[FILE] Use [FILE] to cover
--backcover=[FILE] Use [FILE] to backcover
--generate-toc Generate TOC(Table of Contents)
--no-sandbox Disable Chrome's sandboxing
--debug Run in DEBUG mode
--version Show version
--help Show this help
Run pptrhtmltopdf
or node_modules/.bin/pptrhtmltopdf
Capture https://github.com/netmarkjp/pptrhtmltopdf to ./output.pdf
pptrhtmltopdf https://github.com/netmarkjp/pptrhtmltopdf
Capture https://github.com/netmarkjp/pptrhtmltopdf/blob/master/README.md and https://github.com/netmarkjp/pptrhtmltopdf/blob/master/LICENSE to docs.pdf
with TOC
pptrhtmltopdf --generate-toc --output=docs.pdf \
https://github.com/netmarkjp/pptrhtmltopdf/blob/master/README.md \
https://github.com/netmarkjp/pptrhtmltopdf/blob/master/LICENSE
docker run --rm -it -v $(pwd):/mnt -w /mnt ghcr.io/netmarkjp/pptrhtmltopdf \
--generate-toc \
--output=/mnt/output.pdf \
https://github.com/netmarkjp/pptrhtmltopdf/blob/master/README.md \
https://github.com/netmarkjp/pptrhtmltopdf/blob/master/LICENSE
# build
npm run-script build
# run
npm run-script run -- \
--debug \
--generate-toc \
--output=/path/to/output.pdf \
--cover=/path/to/cover.html \
--backcover=/path/to/backcover.html \
/path/to/i.html \
/path/to/ii.html \
/path/to/iii.html
NOTE:
- Cover(Back Cover) and TOC are not counted within page number.
- Node 18
- Puppeteer 20.7
- pdf-lib 1.2
- pdf-tex-extract 1.5
- TypeScript 5.1
High
- CI/CD
Moderate
- Footer formatting
- Header
- TOC customise
- PDF page size customise