AI Agent Hub
Back to skills
HTML to PDF via Headless Browser icon

HTML to PDF via Headless Browser

Office Efficiency Updated 2026.08.30

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=new if targeting older Edge builds;
  • Print styling: use @media print and @page in the HTML to control A4 page size;
  • Fallback: if headless printing fails, open the HTML in a browser and use Ctrl+P or Cmd+P to 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.