html-to-pdf
БесплатноЗапускает вложенные скриптыНе проверенConvert HTML to PDF with pixel-perfect rendering and excellent Hebrew/RTL support. Use when the user asks to 'convert HTML to PDF', 'generate PDF from HTML'…
от aviz85★ 52 звезды на GitHubОб этом скилле
HTML to PDF Converter
Pixel-perfect HTML to PDF conversion using Puppeteer (Chrome headless). Provides excellent support for Hebrew, Arabic, and other RTL languages with automatic direction detection.
Why Puppeteer?
- Pixel-perfect rendering: Uses actual Chrome engine
- Full CSS3/HTML5 support: Flexbox, Grid, custom fonts, backgrounds
- JavaScript execution: Renders dynamic content
- Automatic RTL detection: Detects Hebrew/Arabic and sets direction
- Web font support: Loads custom fonts properly
Auto-Fit (Built-in, No Flag Needed)
The script automatically handles content overflow:
- Small overflow (up to ~18%) → auto-shrinks font size to fit the page
- Large content → flows cleanly across multiple pages with smart page-break rules (no cutting headers, table rows, or images in half)
- Fits perfectly → does nothing
This runs automatically on every PDF generation. No flags needed.
CRITICAL: Fit Content to Single Page
Backgrounds on html or body cause extra pages! Put backgrounds on a container element instead:
@page { size: A4; margin: 0; }
html, body {
width: 210mm;
height: 297mm;
margin: 0;
padding: 0;
overflow: hidden;
/* NO background here! */
}
.container {
width: 100%;
height: 100%;
padding: 20mm;
box-sizing: border-box;
background: linear-gradient(...); /* Background goes HERE */
}
Common causes of extra pages:
- Background on html/body - always put on
.containerinstead - Content overflow - use
overflow: hidden - Margins/padding pushing content out
Tips:
- Use
--scale=0.75 --margin=0if content still overflows - For landscape: use
--landscape
Setup (One-time)
Before first use, install dependencies:
cd ~/.claude/skills/html-to-pdf && npm install
Quick Usage
Convert local HTML file:
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js input.html output.pdf
Convert URL to PDF:
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js https://example.com page.pdf
Hebrew document with forced RTL:
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js hebrew.html hebrew.pdf --rtl
Pipe HTML content:
echo "<h1>שלום עולם</h1>" | node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js - output.pdf --rtl
Options Reference
| Option | Description | Default |
|---|---|---|
--format=<format> |
Page format: A4, Letter, Legal, A3, A5 | A4 |
--landscape |
Use landscape orientation | false |
--margin=<value> |
Set all margins (e.g., "20mm", "1in") | 20mm |
--margin-top=<value> |
Top margin | 20mm |
--margin-right=<value> |
Right margin | 20mm |
--margin-bottom=<value> |
Bottom margin | 20mm |
--margin-left=<value> |
Left margin | 20mm |
--scale=<number> |
Scale factor 0.1-2.0 | 1 |
--background |
Print background graphics | true |
--no-background |
Don't print backgrounds | - |
--header=<html> |
Header HTML template | - |
--footer=<html> |
Footer HTML template | - |
--wait=<ms> |
Wait time for fonts/JS | 1000 |
--rtl |
Force RTL direction | auto-detect |
--expect-pages=<N> |
Expected page count (warns if different) | 1 |
--no-page-check |
Disable page count warning | - |
Automatic Overflow Detection
The script automatically checks page count after generating the PDF. By default, it expects 1 page and warns if the output has more:
⚠️ WARNING: PAGE OVERFLOW DETECTED!
Expected: 1 page(s)
Actual: 2 page(s)
Fix: Reduce content, margins, or font sizes in HTML
Use --no-page-check to disable this warning
Usage:
- Default: expects 1 page, warns on overflow
--expect-pages=3: expects 3 pages (for multi-page documents)--no-page-check: disables the check entirely
Note: Requires pdfinfo to be installed (part of poppler-utils). If not available, the check is silently skipped.
Examples
Basic conversion:
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js report.html report.pdf
Letter format with custom margins:
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js doc.html doc.pdf --format=Letter --margin=1in
Hebrew invoice:
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js invoice-he.html invoice.pdf --rtl
Landscape presentation:
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js slides.html slides.pdf --landscape --format=A4
No margins (full bleed):
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js poster.html poster.pdf --margin=0
Hebrew/RTL Best Practices
For best Hebrew rendering in your HTML:
- Set lang attribute:
<html lang="he" dir="rtl"> - Use UTF-8:
<meta charset="UTF-8"> - CSS direction: Add
direction: rtl; text-align: right;to body - Fonts: Use web fonts that support Hebrew (Noto Sans Hebrew, Heebo, Assistant)
Example Heb
Установить html-to-pdf в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
BashReadWriteGlobВложенные файлы
FAQ
Что делает скилл html-to-pdf?
Convert HTML to PDF with pixel-perfect rendering and excellent Hebrew/RTL support. Use when the user asks to 'convert HTML to PDF', 'generate PDF from HTML', 'create PDF from webpage', 'export to PDF', or needs PDF generation with Hebrew text support.
Как установить скилл html-to-pdf?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл html-to-pdf запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic