Skip to content

About

Convert HTML to an image, PDF or string

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Convert HTML to an image, PDF or string

Tests License

Convert HTML to an image, PDF or string. Browsershot controls Chrome directly over the DevTools protocol. No Node or Puppeteer installation is needed.

Support us

Support Spatie's open source work

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

Requires Rust 1.89 or newer and an installed Chrome or Chromium browser. See the requirements for installation and custom executable paths.

Add the crate to your Cargo.toml:

[dependencies]
spatie-browsershot = "1"

Usage

use spatie_browsershot::Browsershot;
# fn main() -> Result<(), spatie_browsershot::Error> {

Browsershot::url("https://example.com").save("example.png")?;
Browsershot::html("<h1>Hello world!!</h1>").save("example.pdf")?;
# Ok(())
# }

Only pass URLs and HTML that you trust. Browsershot is not a security boundary for untrusted content.

See the v1 documentation.

Testing

Install Chrome and, if it is not on your PATH, set CHROME_PATH to its executable path. Tests use local fixtures and do not require external websites.

cargo test --locked --all-targets --all-features
cargo test --locked --doc --all-features

See all quality checks. The README and Markdown guides are tested by rustdoc, including setup on hidden # lines.

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md and the Rust API Guidelines.

Using an AI coding agent? Load Apollo's rust-best-practices skill when writing or reviewing code in this package.

Security Vulnerabilities

Report vulnerabilities privately using the instructions in SECURITY.md.

Credits

License

The MIT License (MIT). See LICENSE.md.

About

Convert HTML to an image, PDF or string

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages