html-to-pdf

Convert HTML files and URLs to PDF using Puppeteer. Use when a user needs to convert HTML documents, web pages, or reports to PDF format with custom formatting options (margins, page size, orientation, headers/footers).

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "html-to-pdf" with this command: npx skills add hankagent/html-to-pdf

HTML to PDF Conversion

Convert HTML files and web pages to professional PDF documents using Puppeteer.

Quick Start

CLI Usage

node scripts/html-to-pdf.js input.html output.pdf
node scripts/html-to-pdf.js input.html output.pdf A4
node scripts/html-to-pdf.js https://example.com output.pdf A4

Programmatic Usage

const convertHtmlToPdf = require('./scripts/html-to-pdf.js');

// Simple conversion
await convertHtmlToPdf('input.html', 'output.pdf');

// With options
await convertHtmlToPdf('input.html', 'output.pdf', {
  format: 'Letter',
  landscape: true,
  margin: { top: '20mm', bottom: '20mm' }
});

Features

  • ✅ Convert local HTML files
  • ✅ Convert web URLs (http/https)
  • ✅ Customizable page formats (A4, Letter, etc.)
  • ✅ Custom margins and spacing
  • ✅ Landscape/portrait modes
  • ✅ Print backgrounds
  • ✅ Headers and footers
  • ✅ Page ranges
  • ✅ Zoom scaling

Common Options

OptionTypeDefaultNotes
formatstring'A4'A4, Letter, A3, A5, etc.
landscapebooleanfalseLandscape orientation
marginobject10mm all{ top, right, bottom, left }
scalenumber10.1 to 2.0
printBackgroundbooleantrueInclude background colors
displayHeaderFooterbooleanfalseShow header/footer

Advanced Usage

With Headers and Footers

await convertHtmlToPdf('page.html', 'output.pdf', {
  displayHeaderFooter: true,
  headerTemplate: '<div>Page <span class="pageNumber"></span></div>',
  footerTemplate: '<div>© 2024</div>',
  margin: { top: '40px', bottom: '40px' }
});

Specific Page Ranges

await convertHtmlToPdf('document.html', 'pages-1-5.pdf', {
  pageRanges: '1-5'
});

Installation

Requires Node.js and npm:

npm install puppeteer

Reference

For complete API documentation and all available options, see api.md.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Gigo Lobster Resume

🦞 GIGO · gigo-lobster-resume: 续跑入口:v2 stable 当前会清理旧 checkpoint 并从头重跑;保留此 slug 作为旧 checkpoint 兼容入口。 Triggers: 继续试吃 / 恢复评测 / resume tasting / continue lobster...

Registry SourceRecently Updated
General

YiHui CONTEXT MODE

context-mode is an MCP server that saves 98% of your context window by sandboxing tool outputs. It routes large file reads, shell outputs, and web fetches th...

Registry SourceRecently Updated
General

xinyi-drink

Use when users ask about 新一好喝/新一咖啡 drinks, stores, menu, activities, Skill用户大礼包, today drink recommendations, afternoon tea, feeling sleepy, or personalized...

Registry SourceRecently Updated
General

vedic-destiny

吠陀命盘分析中文入口。用于完整命盘研判、命主盘 Rashi chart 与九分盘 Navamsha chart 联读、既往事件回看、出生时间稳定度判断、事业主题、婚姻主题、时空盘专题,以及基于 Jagannatha Hora PDF、星盘截图或文本命盘数据的系统拆盘。当用户提到完整星盘、事业方向、婚姻问题、关系窗...

Registry SourceRecently Updated