HTML to PDF via Headless Browser
Paste the following prompt into your AI chat to install this skill:
Please install @user_75818cbb/html-to-pdf-new according to https://skillhub.cn/install/skillhub.md.
About this skill
Problem Solved
Converting HTML to PDF often becomes an environment problem: many tools require a separate Chromium, Puppeteer, or container stack. If a machine already has Edge, Chrome, or Chromium, the system browser can print PDF in headless mode. This skill targets that local use case: turn a specified HTML file into a PDF on Windows, macOS, or Linux without adding browser automation dependencies.
How It Works and Where It Applies
The skill locates an available browser by platform priority: Windows checks msedge.exe and chrome.exe; macOS looks for Edge or Chrome; Linux uses which chromium-browser, which chromium, or which google-chrome, and may fall back to fixed paths. It then invokes the browser's --headless and --print-to-pdf behavior, rendering an absolute file:/// path into a PDF.
Important constraints:
- Path format: use forward slashes after
file:///, converting backslashes where needed; - Compatibility: avoid
--headless=newif targeting older Edge builds; - Print styling: use
@media printand@pagein the HTML to control A4 page size; - Fallback: if headless printing fails, open the HTML in a browser and use
Ctrl+PorCmd+Pto save as PDF.
It fits local files, reports, itineraries, and similar HTML-to-PDF tasks; it is not ideal for high-throughput server rendering or machines without a supported system browser.
Use Cases
- Local team turns a generated itinerary HTML into a PDF archive for review.
- Ops prints a local report HTML to PDF using system Edge or Chrome for email.
- Engineers use @media print and @page A4 before headless PDF export.
- Linux users with Chromium convert a preview HTML form into a printable PDF.
Best For
- Frontend engineers who need local HTML reports as PDF without Puppeteer.
- Ops staff who save itinerary, invoice, or print-sheet HTML files to PDF.
- Mac/Windows script authors using system Edge, Chrome, or Chromium for docs.
- Linux ops maintainers who print HTML via an existing headless browser.
Related Skills
Runs rule and semantic checks on Word files, adds comments, and applies GB/T 9704-2012 party/government formatting.
Generate professional .pptx presentations from a topic or outline, with themes, common layouts, speaker notes, and 16:9/4:3 support.
Generates a fixed-structure A-share tech daily across five tracks, screening 24-hour news and selecting leader and growth stocks.
Convert teaching schedules from talent development plan PDFs into structured Excel files, with cross-page tables, merged cells, multi-semester course splitting, major metadata extraction, and batch output.