Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问clear审计提醒

html-to-pdfHTML TO PDF 搜索

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

18,169

周安装

735

GitHub Stars

27

下载量

5,704
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:html-to-pdf(HTML TO PDF 搜索)
来源仓库:https://github.com/aviz85/claude-skills-library
仓库路径:skills/html-to-pdf
安装命令:
npx skills add https://github.com/aviz85/claude-skills-library --skill html-to-pdf
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/aviz85/claude-skills-library --skill html-to-pdf

简介

像素完美的 HTML 到 PDF 转换,具有自动 RTL 和希伯来语语言支持。

  • 使用 Chrome 无头引擎进行渲染,并提供完整的 CSS3/HTML5 支持,包括 Flexbox、Grid、自定义字体和 JavaScript 执行
  • 自动检测希伯来语、阿拉伯语和其他 RTL 语言的从右到左方向;包括--rtl
  • 强制 RTL 模式标志
  • 可配置的页面格式(A4、Letter、Legal、A3、A5)、方向、边距、比例和可选的页眉/页脚
  • 需要一次性 npm 设置;包括有关调整单页内容和验证工作流程的重要指导,以防止文本溢出和截断

SKILL.md

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:

  1. Background on html/body - always put on .container instead
  2. Content overflow - use overflow: hidden
  3. Margins/padding pushing content out

Tips:

  • Use --scale=0.75 --margin=0 if 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

OptionDescriptionDefault
--format=<format>Page format: A4, Letter, Legal, A3, A5A4
--landscapeUse landscape orientationfalse
--margin=<value>Set all margins (e.g., "20mm", "1in")20mm
--margin-top=<value>Top margin20mm
--margin-right=<value>Right margin20mm
--margin-bottom=<value>Bottom margin20mm
--margin-left=<value>Left margin20mm
--scale=<number>Scale factor 0.1-2.01
--backgroundPrint background graphicstrue
--no-backgroundDon't print backgrounds-
--header=<html>Header HTML template-
--footer=<html>Footer HTML template-
--wait=<ms>Wait time for fonts/JS1000
--rtlForce RTL directionauto-detect
--expect-pages=<N>Expected page count (warns if different)1
--no-page-checkDisable 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:

  1. Set lang attribute: <html lang="he" dir="rtl">
  2. Use UTF-8: <meta charset="UTF-8">
  3. CSS direction: Add direction: rtl; text-align: right; to body
  4. Fonts: Use web fonts that support Hebrew (Noto Sans Hebrew, Heebo, Assistant)

Example Hebrew HTML structure (single-page):

<!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>

CRITICAL: Always Use scale=1.0 for Multi-Page PDFs

NEVER use --scale < 1.0 for multi-page documents. It causes:

  • Content offset (not centered on page)
  • RTL text overflow/clipping in grid layouts
  • Unpredictable viewport width calculations

Instead: reduce CSS font sizes and spacing to fit content at scale=1.0.

.page {
  width: 210mm;         /* Matches A4 exactly at scale=1.0 */
  height: 297mm;        /* Matches A4 exactly at scale=1.0 */
  padding: 8mm 10mm 12mm;
  page-break-after: always;
  position: relative;
  background: #f7f8fa;
  overflow: hidden;
  box-sizing: border-box;
}

If content overflows at scale=1.0: reduce font sizes (10-11px base), padding, margins — NOT the scale. This keeps 1:1 mapping between CSS and PDF, eliminating all layout artifacts.

Color tip: Pure white (#fff) backgrounds wash out colored accents. Use #f7f8fa or #f8fafb for subtle contrast that makes colors pop.

Troubleshooting

Fonts not rendering correctly

  • Add --wait=2000 for more font loading time
  • Ensure fonts are loaded via @font-face or Google Fonts

Hebrew appearing left-to-right

  • Use --rtl flag to force RTL direction
  • Add dir="rtl" to your HTML element

Page breaks not working

Use CSS page-break properties:

.page-break { page-break-after: always; }
.no-break { page-break-inside: avoid; }

Backgrounds not showing

  • Ensure --background is set (default is true)
  • Use --no-background only if you want to exclude backgrounds

Auto-Fit Content (MANDATORY VERIFICATION)

CRITICAL - Claude MUST do this after EVERY PDF generation:

  1. Read the PDF file using the Read tool to visually inspect it
  2. Check for vertical overflow (empty pages, content spilling to next page)
  3. Check for horizontal overflow (text cut off at sides)
  4. If ANY issue found → FIX and regenerate (max 5 attempts)
  5. Only deliver PDF to user after verification passes

This is NOT optional. Never deliver a PDF without visual verification.

Problems to Look For

ProblemSymptomFix
Vertical overflowEmpty space at page bottom, content on next pageReduce --scale
Horizontal cut-offText cut at left/right edgesReduce --margin AND fix HTML width
Both issuesContent cut AND extra pagesFix HTML CSS first, then adjust scale

Fix Strategy (Max 5 Attempts)

Attempt 1: Default settings

node scripts/html-to-pdf.js input.html output.pdf

Attempt 2: If vertical overflow → reduce scale

node scripts/html-to-pdf.js input.html output.pdf --scale=0.9

Attempt 3: If horizontal cut-off → reduce margins

node scripts/html-to-pdf.js input.html output.pdf --scale=0.9 --margin=10mm

Attempt 4: If still issues → smaller scale + margins

node scripts/html-to-pdf.js input.html output.pdf --scale=0.8 --margin=5mm

Attempt 5: If still failing → FIX THE HTML CSS:

/* 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;
}

STOP after 5 attempts - regenerate HTML with proper constraints.

HTML Width Fix (Required for Horizontal Fit)

If content is cut at sides, the HTML MUST have:

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;
}

Verification Checklist

After EVERY PDF generation, verify:

  • All text visible (not cut at edges)
  • No unnecessary empty pages
  • Content fills pages properly
  • No large gaps between sections

If ANY check fails → adjust and regenerate (max 5 times).

Technical Notes

  • Uses Puppeteer with Chrome headless for rendering
  • Waits for networkidle0 to ensure all resources load
  • Automatically waits for document.fonts.ready
  • Supports @page CSS rules for print styling
  • Device scale factor set to 2 for crisp rendering

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.58%
按下载量换算1,573

OpenCode

23.99%
按下载量换算1,368

Cursor

16.33%
按下载量换算931

Gemini CLI

12.18%
按下载量换算695

Antigravity

8.41%
按下载量换算480

Codex

3.34%
按下载量换算191

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills