Loading...
Loading...
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.
npx skill4agent add aviz85/claude-skills-library html-to-pdfFirst time? Ifabove, runsetup_complete: falsefirst, then set./SETUP.md.setup_complete: true
htmlbody@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 */
}.containeroverflow: hidden--scale=0.75 --margin=0--landscapecd ~/.claude/skills/html-to-pdf && npm installnode ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js input.html output.pdfnode ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js https://example.com page.pdfnode ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js hebrew.html hebrew.pdf --rtlecho "<h1>שלום עולם</h1>" | node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js - output.pdf --rtl| Option | Description | Default |
|---|---|---|
| Page format: A4, Letter, Legal, A3, A5 | A4 |
| Use landscape orientation | false |
| Set all margins (e.g., "20mm", "1in") | 20mm |
| Top margin | 20mm |
| Right margin | 20mm |
| Bottom margin | 20mm |
| Left margin | 20mm |
| Scale factor 0.1-2.0 | 1 |
| Print background graphics | true |
| Don't print backgrounds | - |
| Header HTML template | - |
| Footer HTML template | - |
| Wait time for fonts/JS | 1000 |
| Force RTL direction | auto-detect |
node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js report.html report.pdfnode ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js doc.html doc.pdf --format=Letter --margin=1innode ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js invoice-he.html invoice.pdf --rtlnode ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js slides.html slides.pdf --landscape --format=A4node ~/.claude/skills/html-to-pdf/scripts/html-to-pdf.js poster.html poster.pdf --margin=0<html lang="he" dir="rtl"><meta charset="UTF-8">direction: rtl; text-align: right;<!DOCTYPE html>
<html lang="he" dir="rtl">
<head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css2?family=Heebo:wght@400;700&display=swap" rel="stylesheet">
<style>
@page { size: A4; margin: 0; }
html, body {
width: 210mm;
height: 297mm;
margin: 0;
padding: 0;
overflow: hidden;
}
.container {
width: 100%;
height: 100%;
padding: 20mm;
box-sizing: border-box;
font-family: 'Heebo', sans-serif;
direction: rtl;
text-align: right;
background: #f5f5f5; /* Background on container, NOT body */
}
</style>
</head>
<body>
<div class="container">
<h1>שלום עולם</h1>
<p>זהו מסמך בעברית</p>
</div>
</body>
</html>--wait=2000@font-face--rtldir="rtl".page-break { page-break-after: always; }
.no-break { page-break-inside: avoid; }--background--no-background| Problem | Symptom | Fix |
|---|---|---|
| Vertical overflow | Empty space at page bottom, content on next page | Reduce |
| Horizontal cut-off | Text cut at left/right edges | Reduce |
| Both issues | Content cut AND extra pages | Fix HTML CSS first, then adjust scale |
node scripts/html-to-pdf.js input.html output.pdfnode scripts/html-to-pdf.js input.html output.pdf --scale=0.9node scripts/html-to-pdf.js input.html output.pdf --scale=0.9 --margin=10mmnode scripts/html-to-pdf.js input.html output.pdf --scale=0.8 --margin=5mm/* Add to HTML to prevent horizontal overflow */
.container {
width: 100%;
max-width: 100%;
overflow-wrap: break-word;
word-wrap: break-word;
box-sizing: border-box;
}html, body {
width: 210mm; /* A4 width */
margin: 0;
padding: 0;
overflow: hidden;
}
.container {
width: 100%;
max-width: 100%;
padding: 15mm;
box-sizing: border-box;
overflow-wrap: break-word;
}networkidle0document.fonts.ready@page