web page to pdf

Other

Convert web pages to PDF files using Playwright, saving them in A4 format with margins after fully loading the page.

Install

openclaw skills install convert-pdf

Web to PDF Converter

Convert web pages to PDF files using Playwright.

Usage

python pdf2.py <url> [output_filename]

Examples

# Convert a webpage to PDF (uses domain name as filename)
python pdf2.py https://example.com

# Specify custom output filename
python pdf2.py https://example.com my-document.pdf

# Short URL (https:// is added automatically)
python pdf2.py example.com output.pdf

Setup

If playwright is not installed:

pip install playwright
playwright install chromium

Script Location

The script is located at: skills/web2pdf/scripts/pdf2.py

Notes

  • The script uses Chromium via Playwright for accurate rendering
  • Waits for network idle before PDF generation to ensure page is fully loaded
  • Output is saved to the current working directory
  • A4 format with 20px margins is used by default