← 返回
效率工具

Pdf Generator

Generate professional PDFs from Markdown, HTML, data, or code. Reports, invoices, contracts, and documents with best practices.
从Markdown、HTML、数据或代码生成专业PDF。支持报告、发票、合同等符合最佳实践的文档。
ivangdavila
效率工具 clawhub v1.0.1 1 版本 98938 Key: 无需
★ 20
Stars
📥 11,059
下载
💾 1,197
安装
1
版本
#latest

概述

When to Use

User needs to create, generate, or export PDF documents. Agent handles document generation from multiple sources (Markdown, HTML, JSON, templates), formatting, styling, and batch processing.

Scope

This skill ONLY:

  • Provides code patterns and implementation guidance for PDF generation
  • Explains tool selection, CSS for print, and document structure
  • Shows reference examples for common document types

This skill NEVER:

  • Executes code or generates files directly
  • Makes network requests
  • Accesses files outside user's working directory

All code examples are reference patterns for the user to implement.

Quick Reference

TopicFile
-------------
Tool selectiontools.md
Document typestemplates.md
Advanced operationsadvanced.md

Core Rules

1. Choose the Right Tool

SourceBest ToolWhy
------------------------
MarkdownpandocNative support, TOC, templates
HTML/CSSweasyprintBest CSS support, no LaTeX
Data/JSONreportlabProgrammatic, precise control
Simple textfpdf2Lightweight, fast

Default recommendation: weasyprint for most HTML-based documents.

2. Structure Before Style

# CORRECT: semantic structure
html = """
<article>
  <header><h1>Report Title</h1></header>
  <section>
    <h2>Summary</h2>
    <p>Content...</p>
  </section>
</article>
"""

# WRONG: style-first approach
html = "<div style='font-size:24px'>Report Title</div>"

3. Handle Page Breaks Explicitly

/* Force page break before */
.new-page { page-break-before: always; }

/* Keep together */
.keep-together { page-break-inside: avoid; }

/* Headers never orphaned */
h2, h3 { page-break-after: avoid; }

4. Always Set Metadata

# Example pattern for weasyprint
html = """
<html>
<head>
  <title>Document Title</title>
  <meta name="author" content="Author Name">
</head>
...
"""

5. Use Print-Optimized CSS

@media print {
  body {
    font-family: 'Georgia', serif;
    font-size: 11pt;
    line-height: 1.5;
  }
  
  @page {
    size: A4;
    margin: 2cm;
  }
  
  .no-print { display: none; }
}

6. Validate Output

After generating any PDF:

  1. Check file size (0 bytes = failed)
  2. Open and verify page count
  3. Verify fonts render correctly

Common Traps

TrapConsequenceFix
------------------------
Missing fontsFallback to defaultsUse web-safe fonts
Absolute image pathsImages missingUse relative paths
No page sizeUnpredictable layoutSet @page { size: A4; }
Large imagesHuge filesCompress before use

Security & Privacy

This is a reference skill. It provides patterns and guidance only.

Data that stays local:

  • All PDF generation happens on user's machine
  • No data sent externally

This skill does NOT:

  • Execute code or make files
  • Make network requests
  • Access system files

Feedback

  • If useful: clawhub star pdf-generator
  • Stay updated: clawhub sync

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-28 11:14 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 437 📥 147,168
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,349 📥 317,696
productivity

Baidu web search

ide-rea
使用百度AI搜索引擎(BDSE)进行网络搜索。适用于获取实时信息、文档资料或研究课题。
★ 236 📥 105,301