返回顶部
h

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).

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
266
下载量
0
收藏
概述
安装方式
版本历史

html-to-pdf

# HTML to PDF Conversion Convert HTML files and web pages to professional PDF documents using Puppeteer. ## Quick Start ### CLI Usage ```bash 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 ```javascript 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 | Option | Type | Default | Notes | |--------|------|---------|-------| | format | string | 'A4' | A4, Letter, A3, A5, etc. | | landscape | boolean | false | Landscape orientation | | margin | object | 10mm all | { top, right, bottom, left } | | scale | number | 1 | 0.1 to 2.0 | | printBackground | boolean | true | Include background colors | | displayHeaderFooter | boolean | false | Show header/footer | ## Advanced Usage ### With Headers and Footers ```javascript 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 ```javascript await convertHtmlToPdf('document.html', 'pages-1-5.pdf', { pageRanges: '1-5' }); ``` ## Installation Requires Node.js and npm: ```bash npm install puppeteer ``` ## Reference For complete API documentation and all available options, see [api.md](references/api.md).

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 html-to-pdf-1776027488 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 html-to-pdf-1776027488 技能

通过命令行安装

skillhub install html-to-pdf-1776027488

下载 Zip 包

⬇ 下载 html-to-pdf v1.0.0

文件大小: 4.4 KB | 发布时间: 2026-4-13 10:35

v1.0.0 最新 2026-4-13 10:35
Initial release: Convert HTML files and URLs to PDF using Puppeteer

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部