Convert HTML to an image, PDF or string. Browsershot controls Chrome directly over the DevTools protocol. No Node or Puppeteer installation is needed.
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.
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"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.
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-featuresSee all quality checks. The README and Markdown guides are tested by rustdoc, including setup on hidden # lines.
See CHANGELOG.md.
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.
Report vulnerabilities privately using the instructions in SECURITY.md.
The MIT License (MIT). See LICENSE.md.
