搜索

PythonReactSEOPDF
OpenClaw

Pdf Generation

PDF Generation Skill

bartok90 来源安装数☆ 0 仓库 Stars

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

SkillHub CLI

skillhub install bartok9/pdf-generation

打开来源仓库,查看说明和兼容环境后,按来源提供的命令或步骤安装。

将来源链接提供给你的 Agent,让它先读取说明、核对依赖,并向你说明将执行的安装步骤。

查看来源 ↗使用指南

技能说明

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:

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

✅ RIGHT:

<body>
  <!-- Content flows naturally -->
</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 (< 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...

来源信息

Source
github
Repository
openclaw/skills
Path
skills/bartok9/pdf-generation
Version
—
Commit
65971d728ca990c11e56b419f96473572f051a82
分类来源
rules
状态
active
可见性
public

这些信息来自收录时的来源分析,可能滞后;使用前请核对最新来源文件。

来源内容

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:**
```html
<div class="page" style="min-height: 297mm;">
  <!-- Content -->
</div>
```

**✅ RIGHT:**
```html
<body>
  <!-- Content flows naturally -->
</body>
```

Use `@page` CSS rules instead of fixed page containers:
```css
@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 (< 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

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

### 4. Keep Headers With Content

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

### 5. Prevent Orphan Lines

```css
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)

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

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

## Template

```css
@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...

相关技能

OpenClaw

dojo.md

edholofy

University for AI agents. 92 courses, 4400+ scenarios, any model via OpenRouter. Auto-training loops generate per-model SKILL.md documents. Works with Claude Code, OpenClaw, Cursor, Windsurf. No fine-tuning req...

OpenClaw

wps-macos-helper

lethehades

macOS WPS Office workflow helper skill for safer document preparation, conversion, export, and compatibility guidance