Skip to content

Instantly share code, notes, and snippets.

@fieldse
Created May 13, 2024 15:06
Show Gist options
  • Save fieldse/69984796a7733042e67475020b3bcfc3 to your computer and use it in GitHub Desktop.
Save fieldse/69984796a7733042e67475020b3bcfc3 to your computer and use it in GitHub Desktop.
Download webpage as PDF using headless Chrome

Save webpage to PDF using headless Chromium

credit: user Keavon at reddit.com/r/DataHoarder

  1. Install chromium from NPM
npm install chromium
  1. Download page with headless Chomium
CHROME_PATH="$(pwd)/node_modules/chromium/lib/chromium/chrome-linux/chrome"

$CHROME_PATH --headless --no-sandbox --disable-gpu --disable-web-security --run-all-compositor-stages-before-draw --virtual-time-budget=5000 --font-render-hinting=none --print-to-pdf=OUTPUT.pdf https://example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment