Batch convert HTML files to PDF using PowerShell and wkhtmltopdf.
This script automatically processes all HTML files in its folder and saves the converted PDFs in an output directory.
- Converts all
.htmlfiles in the script’s directory to PDF - Uses wkhtmltopdf for high-quality PDF generation
- Output PDFs are stored in an organized
outputfolder - Optimized conversion settings: A4, landscape, no smart shrinking
- wkhtmltopdf installed and available in your system PATH, or know its full path
-
Download or clone this repository.
-
Place the PowerShell script in the folder containing your
.htmlfiles. -
Open PowerShell in that folder.
-
(Optional, if you encounter execution policy errors) Run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
This temporarily allows script execution for this PowerShell session only.
-
Run the script:
.\convert-html-to-pdf.ps1
- PDFs will appear in the
outputsubfolder.
- PDFs will appear in the
- If
wkhtmltopdf.exeis not in your PATH, edit the line in the script:$wkhtmltopdf = "C:\Path\To\wkhtmltopdf.exe"