Skip to content

desktop-commander/html2pdf-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

HTML to PDF Skill

A comprehensive skill for creating beautiful PDFs from HTML/CSS with precise control over typography, layout, colors, and design.

Overview

This skill enables AI assistants to create stunning, professional PDFs using familiar HTML and CSS instead of low-level PDF libraries. It provides design freedom, visual development, and precise control over page breaks, margins, and print layouts.

Features

  • Modern Web Technologies: Use HTML5 and CSS3 to design professional documents
  • Multiple Tools: Support for Playwright (recommended), WeasyPrint, and pdfkit
  • Design Freedom: Full control over typography, layouts, colors, and gradients
  • Visual Development: See your design in a browser before converting to PDF
  • Page Break Control: Precise control over pagination and print layouts

Installation

Playwright (Recommended)

pip install playwright --break-system-packages
playwright install chromium

WeasyPrint (Alternative)

pip install weasyprint --break-system-packages

Quick Start

Create an HTML document and convert it to PDF using Playwright:

from playwright.sync_api import sync_playwright

def html_to_pdf_playwright(html_file, pdf_file):
    with sync_playwright() as p:
        browser = p.chromium.launch()
        page = browser.new_page()
        page.goto(f'file://{html_file}')
        page.pdf(
            path=pdf_file,
            format='A4',
            print_background=True,
            margin={'top': '0', 'right': '0', 'bottom': '0', 'left': '0'}
        )
        browser.close()

Use Cases

  • Reports, proposals, and presentations
  • Invoices, certificates, and official documents
  • Multi-page documents with consistent styling
  • Marketing materials and brochures
  • Any document where visual design matters

Documentation

See SKILL.md for comprehensive documentation including:

  • Detailed usage examples
  • CSS best practices for PDF
  • Advanced techniques (headers, footers, custom fonts)
  • Complete workflow examples
  • Troubleshooting guide

Created With

This skill was created using Desktop Commander - an MCP server that enables AI assistants to interact with your local file system and execute commands.

License

MIT

About

Create beautiful PDFs from HTML/CSS with precise control over typography, layout, and design

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors