Skip to content

Instantly share code, notes, and snippets.

@jamesdaily
Created February 7, 2019 19:55
Show Gist options
  • Save jamesdaily/05887de933d131549cb69e4829d466f4 to your computer and use it in GitHub Desktop.
Save jamesdaily/05887de933d131549cb69e4829d466f4 to your computer and use it in GitHub Desktop.
Windows Batch file to invoke "print-to-pdf" feature in headless Chrome
@echo off
IF %1.==. GOTO NoHtmlFile
SET CURRENTDIR=%cd%
set htmlFile=%1
start "C:\Program Files (x86)\Google\Chrome\Application" chrome.exe --headless --disable-gpu --no-margins --print-to-pdf="%CURRENTDIR%\%htmlFile%.pdf" "%CURRENTDIR%\%htmlFile%"
GOTO End1
:NoHtmlFile
ECHO Must specify HTML file or URL
GOTO End1
:End1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment