Darin Gordon
Entrepreneur
Darin Gordon
RustNYC - July 2019
- Websockets using DevTools Protocol
- Command line
Screenshots
Render PDF
Pyppeteer
rust-headless-chrome
Some languages ported the API really well
(and others did it their own way)
unofficial logo
PDF Generation
let browser = Browser::connect(chrome_url)?;
let tab = browser.wait_for_initial_tab()?;
let local_pdf = tab
.navigate_to(&uri)?
.wait_until_navigated()?
.print_to_pdf(pdf_options)?;
fs::write("report.pdf", &local_pdf)?;Screen Snapshot
let browser = Browser::default()?;
let tab = browser.wait_for_initial_tab()?;
tab.navigate_to("https://www.wikipedia.org")?;
tab.wait_for_element("input#searchInput")?;
let jpeg_data = tab.capture_screenshot(
ScreenshotFormat::JPEG(Some(75)),
None,
true)?;
fs::write("page.jpg", &jpeg_data)?;
A Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF.
Gotenberg
1.7GB Docker Image, 1GB+ stripped
So... I wrote my own service in Rust!
So... I wrote my own service in Rust! (continued)
musl cross-compiled static exec binary:
headless chrome + alpine:
service binary + alpine:
(headless chrome is the bottleneck)
So... I wrote my own service in Rust! (continued)
Would you like to walk through the code together next time?
Questions?
By Darin Gordon