← 返回 Skills 市场
bartok9

PDF Generation

作者 Bartok9 · GitHub ↗ · v1.0.0
cross-platform ✓ 安全检测通过
817
总下载
2
收藏
5
当前安装
1
版本数
在 OpenClaw 中安装
/install pdf-generation
功能描述
Generate professional PDFs from HTML/CSS using flow layouts and selective break controls to avoid whitespace gaps and layout issues in printed pages.
使用说明 (SKILL.md)

PDF Generation Skill

Purpose: Generate professional PDFs from HTML/CSS without whitespace gaps or layout issues.

The Problem

When generating PDFs from HTML, page-break-inside: avoid causes orphan whitespace — content that can't fit on the current page gets pushed entirely to the next page, leaving huge gaps.

The Solution

1. Use Flow-Based Layout (NOT Fixed Page Containers)

❌ WRONG:

\x3Cdiv class="page" style="min-height: 297mm;">
  \x3C!-- Content -->
\x3C/div>

✅ RIGHT:

\x3Cbody>
  \x3C!-- Content flows naturally -->
\x3C/body>

Use @page CSS rules instead of fixed page containers:

@page {
    size: A4;
    margin: 18mm 15mm;
}

2. Protect ONLY Small Elements

Only use break-inside: avoid on elements that:

  • Are small (cards, single rows, short boxes)
  • Would look broken if split

✅ Protect:

  • Individual table rows (tr)
  • Cards (\x3C 100px tall)
  • Timeline items
  • Step items
  • Highlight boxes

❌ Do NOT Protect:

  • Entire tables
  • Large containers
  • Entire sections
  • Multi-column layouts
  • Quote boxes at document end

3. Use Modern + Legacy Properties

.small-element {
    break-inside: avoid;        /* Modern spec */
    page-break-inside: avoid;   /* Legacy support */
}

4. Keep Headers With Content

h2, h3, h4, .section-header {
    break-after: avoid;
    page-break-after: avoid;
}

5. Prevent Orphan Lines

body {
    orphans: 3;  /* Min lines at bottom of page */
    widows: 3;   /* Min lines at top of page */
}

6. Allow Tables to Break (But Keep Rows Together)

table {
    /* NO break-inside: avoid */
}

tr {
    break-inside: avoid;
    page-break-inside: avoid;
}

Template

@page {
    size: A4;
    margin: 18mm 15mm;
}

body {
    font-size: 10pt;
    line-height: 1.5;
    orphans: 3;
    widows: 3;
}

/* Headers stay with content */
h2, h3, h4 {
    break-after: avoid;
    page-break-after: avoid;
}

/* Small elements don't break */
.card, .highlight-box, .step, .timeline-item {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Table rows stay together, table can break */
tr {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Large containers flow naturally */
table, .section, .two-col {
    /* NO break-inside: avoid */
}

@media print {
    body { 
        -webkit-print-color-adjust: exact; 
        print-color-adjust: exact; 
    }
}

Tools

Tool Use Case Install
WeasyPrint HTML/CSS → PDF (best CSS support) brew install weasyprint or pip install weasyprint
Pandoc Markdown → PDF via LaTeX brew install pandoc
wkhtmltopdf Complex layouts Download from wkhtmltopdf.org
Puppeteer JS-rendered content npm install puppeteer

WeasyPrint Command

weasyprint input.html output.pdf

Pre-Flight Checklist

Before sending ANY PDF:

  • Open in PDF viewer, scroll through ALL pages
  • Check for large whitespace gaps between content
  • Ensure no single-line orphans at page tops
  • Verify tables don't have awkward mid-row breaks
  • Confirm headers are followed by content (not at page bottom alone)

Common Mistakes

Mistake Fix
page-break-inside: avoid on large containers Remove it, let content flow
Fixed-height page divs Use @page rules instead
Quote box at document end with break protection Remove break protection
Entire table protected from breaking Only protect tr, not table
No orphans/widows set Add orphans: 3; widows: 3;

Resources


Skill created by Bartok — March 6, 2026

安全使用建议
This skill is an instruction-only guide for producing better print PDFs from HTML/CSS and is internally consistent. Before using: ensure any CLI tools the agent runs (weasyprint, wkhtmltopdf, puppeteer, pip/npm installs) come from sources you trust; running suggested install commands will install third-party software on your machine. Because the skill contains executable command examples, only allow it to run those commands if you trust the environment and the agent's actions.
功能分析
Type: OpenClaw Skill Name: pdf-generation Version: 1.0.0 The skill bundle provides legitimate documentation and CSS templates for improving PDF generation from HTML/CSS. It contains standard layout advice, tool recommendations (e.g., WeasyPrint, Puppeteer), and a checklist for the agent, with no evidence of malicious code, data exfiltration, or prompt injection attacks.
能力评估
Purpose & Capability
Name/description match the content: SKILL.md is focused on print/CSS layout techniques and recommends PDF generation tools (WeasyPrint, wkhtmltopdf, Puppeteer, Pandoc), which are appropriate for the stated purpose.
Instruction Scope
Instructions are limited to CSS guidance, templates, checklists, and example CLI commands (weasyprint input.html output.pdf). They do not instruct reading unrelated system files, accessing environment variables, or exfiltrating data.
Install Mechanism
This is an instruction-only skill with no install spec and no code files. It only suggests common package installs (brew/pip/npm) and a vendor download for wkhtmltopdf, which is proportional and expected for PDF tooling.
Credentials
The skill declares no required environment variables, credentials, or config paths. The instructions do not reference secrets or unrelated services.
Persistence & Privilege
always is false and the skill does not request persistent system privileges or modify other skills or system-wide settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install pdf-generation
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /pdf-generation 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release: Fix HTML-to-PDF whitespace gaps. Flow-based layout, proper break-inside rules, WeasyPrint best practices.
元数据
Slug pdf-generation
版本 1.0.0
许可证
累计安装 5
当前安装数 5
历史版本数 1
常见问题

PDF Generation 是什么?

Generate professional PDFs from HTML/CSS using flow layouts and selective break controls to avoid whitespace gaps and layout issues in printed pages. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 817 次。

如何安装 PDF Generation?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install pdf-generation」即可一键安装,无需额外配置。

PDF Generation 是免费的吗?

是的,PDF Generation 完全免费(开源免费),可自由下载、安装和使用。

PDF Generation 支持哪些平台?

PDF Generation 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 PDF Generation?

由 Bartok9(@bartok9)开发并维护,当前版本 v1.0.0。

💬 留言讨论