Converts HTML files to PDF or PNG format.
This skill helps you convert HTML files to PDF or PNG format with various options for output quality and page layout.
Use this skill when the user wants to:
Best for: Printing, archiving, traditional documents
Command:
python html_to_pdf_final.py input.html output.pdf
Features:
Best for: Online viewing, presentations, no page breaks
Command:
python html_to_long_image.py input.html
Features:
.png and .pdfBest for: Fallback options, compatibility
Command:
python html_to_pdf_converter.py input.html output.pdf
Features:
The skill requires Playwright and Pillow. The scripts auto-install dependencies if missing:
pip install playwright pillow pypdf
playwright install chromium
Verify the HTML file exists:
ls -la *.html
Run the converter:
python html_to_pdf_final.py your_file.html
Open the result:
open your_file_final.pdf
Verify the HTML file exists:
ls -la *.html
Run the long image converter:
python html_to_long_image.py your_file.html
Check outputs:
# View the PNG screenshot
open your_file_fullpage.png
# View the PDF version
open your_file_fullpage.pdf
Solution:
playwright install chromium
Solution: Use the long image method instead:
python html_to_long_image.py your_file.html
Causes & Solutions:
Solution: Use the long image method which uses screenshot instead of PDF rendering:
python html_to_long_image.py your_file.html
After conversion, you'll get:
Multi-Page PDF:
filename_final.pdf - Standard A4 multi-page PDFLong Image Method:
filename_fullpage.png - Complete screenshot as PNG (6-10 MB)filename_fullpage.pdf - Single-page PDF from image (1-2 MB)For online viewing/presentations: Use html_to_long_image.py
For printing/archiving: Use html_to_pdf_final.py
For complex CSS: Use html_to_pdf_converter.py
All scripts should be in the project directory:
html_to_pdf_final.py - Main multi-page converterhtml_to_long_image.py - Long image generatorhtml_to_pdf_converter.py - Advanced multi-method converterpython html_to_pdf_final.py 202510_Alpha_Intelligence_BP.html
# Output: 202510_Alpha_Intelligence_BP_final.pdf (22 pages, 5.7 MB)
python html_to_long_image.py 202510_Alpha_Intelligence_BP.html
# Output:
# - 202510_Alpha_Intelligence_BP_fullpage.png (6.1 MB)
# - 202510_Alpha_Intelligence_BP_fullpage.pdf (1.6 MB, 1 page)
for file in *.html; do
python html_to_long_image.py "$file"
done
python html_to_pdf_final.py input.html custom_output.pdf
python html_to_long_image.py input.html
python -c "from pypdf import PdfReader; r = PdfReader('output.pdf'); print(f'Pages: {len(r.pages)}')"
ls -lh *.pdf *.png
A successful conversion should:
| Need | Use | Output |
|---|---|---|
| Printing | html_to_pdf_final.py |
Multi-page A4 PDF |
| Online viewing | html_to_long_image.py |
Single-page PDF + PNG |
| Maximum compatibility | html_to_pdf_converter.py |
Multi-page PDF with fallbacks |