Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ilaborie/html2pdf
Just a CLI over the headless_chrome https://crates.io/crates/headless_chrome crate to render a PDF from a local HTML file
https://github.com/ilaborie/html2pdf
Last synced: 2 days ago
JSON representation
Just a CLI over the headless_chrome https://crates.io/crates/headless_chrome crate to render a PDF from a local HTML file
- Host: GitHub
- URL: https://github.com/ilaborie/html2pdf
- Owner: ilaborie
- License: apache-2.0
- Created: 2021-07-22T18:39:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-23T11:15:15.000Z (16 days ago)
- Last Synced: 2024-12-30T00:09:43.443Z (9 days ago)
- Language: Rust
- Homepage:
- Size: 127 KB
- Stars: 34
- Watchers: 3
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# html2pdf
[![Docs](https://docs.rs/html2pdf/badge.svg)](https://docs.rs/html2pdf)
[![Crates.io](https://img.shields.io/crates/v/html2pdf.svg?maxAge=2592000)](https://crates.io/crates/html2pdf)Just a CLI over the [`headless_chrome`](https://crates.io/crates/headless_chrome) crate to create PDF.
## Install
Need the Rust toolchain: .
```shell
cargo install html2pdf
```## Usage
```shell
html2pdf path/to/file.html
```To remove logs, set the env var `RUST_LOG` to `none` :
```shell
RUST_LOG="none" html2pdf path/to/file.html
```## Options
Just run `html2pdf --help` :
```shell
html2pdf 0.4.0
Generate a PDF from a local HTML file using a headless chromeUSAGE:
html2pdf [FLAGS] [OPTIONS]FLAGS:
--background Allow print background
-h, --help Prints help information
--landscape Use landscape mode
--disable-sandbox Disable Chrome sandbox. Not recommended, unless running on docker-V, --version Prints version information
OPTIONS:
--footer HTML template for the print footer. Should use the same format as the headerTemplate
--header HTML template for the print header. Should be valid HTML markup with following classes used
to inject printing values into them: date for formatted print date, title for document
title, url for document location, pageNumber for current page number, totalPages for total
pages in the document. For example, `` would generate span
containing the title
--margin Margin in inches You can define margin like this: '0.4' the value is applied for all side,
'0.4 0.4' : first value is applied for top and bottom, second for left and right, '0.4 0.4
0.4 0.4' : first value is applied for top then, right, then bottom, and last for left
-o, --output Output file. By default, just change the input extension to PDF
--paper Paper size. Supported values: A4, Letter, A3, Tabloid, A2, A1, A0, A5, A6
--range Paper ranges to print, e.g. '1-5, 8, 11-13'
--scale Scale, default to 1.0
--wait Time to wait in ms before printing. Examples: 150ms, 10sARGS:
Input HTML file
```