https://github.com/netmarkjp/pptrhtmltopdf
Convert HTML to PDF using Chrome (Puppeteer)
https://github.com/netmarkjp/pptrhtmltopdf
chrome chrome-headless headless-chrome node pdf puppeteer wkhtmltopdf
Last synced: about 21 hours ago
JSON representation
Convert HTML to PDF using Chrome (Puppeteer)
- Host: GitHub
- URL: https://github.com/netmarkjp/pptrhtmltopdf
- Owner: netmarkjp
- License: apache-2.0
- Created: 2019-11-23T00:44:44.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-20T23:32:39.000Z (over 1 year ago)
- Last Synced: 2025-08-14T12:59:47.072Z (about 2 months ago)
- Topics: chrome, chrome-headless, headless-chrome, node, pdf, puppeteer, wkhtmltopdf
- Language: TypeScript
- Homepage:
- Size: 350 KB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pptrhtmltopdf
Convert HTML to PDF using Chrome (Puppeteer)
Export PDF from Websites or HTML Files.
Alterative of [wkhtmltopdf](https://wkhtmltopdf.org/) but pptrhtmltopdf uses Headless Chrome.
- Add cover page :ok:
- Add backcover page :ok:
- Generate TOC page :ok:
- Support multi HTML :ok:
- Support local HTML :ok:
- Support Website :ok:Output PDF Example: [examples/output-examples.pdf](examples/output-example.pdf)
# Install
```bash
npm install pptrhtmltopdf
```# Usage
```bash
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`
## Example
### Capture https://github.com/netmarkjp/pptrhtmltopdf to `./output.pdf`
```bash
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
```bash
pptrhtmltopdf --generate-toc --output=docs.pdf \
https://github.com/netmarkjp/pptrhtmltopdf/blob/master/README.md \
https://github.com/netmarkjp/pptrhtmltopdf/blob/master/LICENSE
```# Run on Docker
```bash
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
```# Development
```
# 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.
# Stack
- Node 18
- Puppeteer 20.7
- pdf-lib 1.2
- pdf-tex-extract 1.5
- TypeScript 5.1# TODO
High
- CI/CD
Moderate
- Footer formatting
- Header
- TOC customise
- PDF page size customise