| name | html-to-pdf |
| description | Convert HTML to PDF using the fulgur CLI (npx @fulgur-rs/cli). Generates HTML from a description if no file is provided. |
HTML to PDF
Use this skill when the user wants to convert an HTML file to PDF, or wants to create a PDF document from scratch.
Workflow
Step 1 — Determine the HTML source
- If the user provides an HTML file path, use it directly.
- If no HTML is provided, ask for the document's purpose and content, then generate the HTML and save it to a temporary file (e.g.
output.html).
When generating HTML, produce clean, print-ready markup:
- Use inline styles or a
<style> block — no external stylesheets unless the user provides one.
- Set appropriate page dimensions via CSS (
@page { size: A4; margin: 20mm; }).
- Use web-safe fonts or note that custom fonts can be bundled with
-f.
Step 2 — Determine conversion options
Infer from context or ask if unclear:
| Option | Flag | Default |
|---|
| Page size | -s A4 | Letter | A3 | A4 |
| Landscape | -l | portrait |
| Margin (mm) | --margin "top right bottom left" | browser default |
| Font file | -f path/to/font.ttf | none |
| Extra CSS | --css path/to/style.css | none |
| Image | -i name=path/to/image.png | none |
| JSON data | -d path/to/data.json | none |
Step 3 — Run the conversion
npx @fulgur-rs/cli render -o <output>.pdf [options] <input>.html
Examples:
npx @fulgur-rs/cli render -o output.pdf input.html
npx @fulgur-rs/cli render -o output.pdf -s A4 -l --margin "15 20" input.html
npx @fulgur-rs/cli render -o output.pdf -f NotoSansJP.ttf input.html
npx @fulgur-rs/cli render -o invoice.pdf -d data.json template.html
Step 4 — Report completion
Tell the user where the PDF was saved. If the conversion fails, show the error output and suggest fixes (missing font, malformed HTML, etc.).