agentsclimarketplace

Html to pdf

Skill yugasun/skills/skills/html-to-pdf

A collection of high-quality, opinionated agent skills for modern full-stack development. These skills are designed to be used with AI agents (like Cursor, Windsurf, or custom agents) to standardize project creation and maintenance.

Install
npx -y skills add yugasun/skills --skill html-to-pdf

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Export HTML files to PDF using Playwright with mobile emulation and custom viewport settings. Use this skill when the user asks to convert HTML to PDF, export presentations to PDF, or generate PDF documents from web pages.

SKILL.md

2.8 KB, as published. Nobody here has run it

HTML to PDF Export

Export HTML files (local or URLs) to PDF using Playwright with configurable viewport and mobile emulation.

Quick Start

Use the provided script to export HTML to PDF:

uv run {baseDir}/scripts/export_to_pdf.py input.html output.pdf

Export urls:

uv run {baseDir}/scripts/export_to_pdf.py https://example.com output.pdf

Key Features

  • Mobile Emulation: 768px viewport for mobile-optimized rendering
  • Background Printing: Preserves colors and backgrounds
  • Dynamic Content: Waits for JavaScript execution (ECharts, animations, etc.)
  • Full Page Capture: Auto-detects page height for complete output
  • Debug Mode: Visual inspection before PDF generation

Technical Details

Viewport Configuration

  • Width: 768px (matches CSS @media (max-width: 768px) breakpoint)
  • Height: 1024px initial, expands to full content
  • Device Scale: 2x for retina displays
  • Mobile Mode: Enabled to trigger mobile-specific behaviors

Rendering Pipeline

  1. Load: Opens URL in Chromium browser with mobile viewport
  2. Wait: Network idle + 10s buffer for JS execution
  3. Measure: Calculates full page height via scrollHeight
  4. Export: Generates PDF with exact dimensions
  5. Cleanup: Closes browser and context

Wait Times

Default wait: 10 seconds after network idle

Adjust for heavy JS/animations:

# In export_to_pdf.py, modify:
page.wait_for_timeout(15000)  # 15 seconds

Dependencies

Install Playwright:

pip install playwright
playwright install chromium

Common Use Cases

  1. Slide Decks: Export presentation HTML with animations and charts
  2. Reports: Convert dynamic dashboards to static PDFs
  3. Documentation: Generate PDF versions of web documentation
  4. Newsletters: Archive HTML emails as PDFs

Troubleshooting

Missing Backgrounds

Already handled by injecting:

body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

Content Cut Off

The script auto-detects page height. If issues persist:

  • Check if content is position: fixed/absolute
  • Verify viewport width triggers correct CSS breakpoints
  • Increase wait timeout for slow-loading content

Charts Not Rendering

Increase wait time in script:

page.wait_for_timeout(15000)  # or more

Script Reference

See scripts/export_to_pdf.py for the complete implementation. The script is self-contained and can be used directly from the command line or imported as a module.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.