AgentSkillsCN

pdf

处理 PDF 文件的操作,包括表单填写、文本与表格提取,以及高保真生成。在制作专业 PDF 报告、合并文档,以及自动化表单处理时,可灵活运用此方法。当视觉质量与准确性验证至关重要时,应主动展开相关工作。 示例: - 用户:“填写这份 PDF 表单并进行验证” → 填充表单字段,并仔细检查图像内容 - 用户:“合并这些报告并添加水印” → 使用 pypdf 工具 - 用户:“将这张复杂的表格提取到 Excel 中” → 使用 pdfplumber 工具,确保布局的完整性与准确性

SKILL.md
--- frontmatter
name: pdf
description: |-
  Handle PDF manipulation, form filling, text/table extraction, and high-fidelity generation. Use for professional PDF reports, merging documents, and automated form processing. Use proactively when visual quality and verification are critical.
  
  Examples:
  - user: "Fill this PDF form and verify" -> populate fields and inspect images
  - user: "Merge these reports and add a watermark" -> use pypdf
  - user: "Extract this complex table to Excel" -> use pdfplumber for layout preservation
<instructions> <instructions> # PDF Professional Suite

🛠 High-Fidelity Creation

When generating polished reports:

  1. Generate: Use Reportlab (programmatic) or Platypus (templated) as the primary engine.
  2. Preview: Convert every page to PNG for inspection:
    • pdftoppm -png -r 150 document.pdf page
  3. Inspect: Verify that charts, tables, and typography are sharp and well-aligned.

📋 Common Operations

1. Form Filling

  • Identify fillable fields using scripts/extract_form_field_info.py.
  • Reference: See references/forms.md for detailed instructions on filling PDF forms.
  • Populate fields programmatically and verify using the Render loop.

2. Manipulation (pypdf)

  • Merge: Use PdfWriter to combine multiple documents.
  • Split: Extract individual pages into new files.
  • Secure: Add passwords or watermarks using PdfWriter.encrypt().
  • Reference: See references/reference.md for advanced features and JS library alternatives.

3. Extraction (pdfplumber)

  • Extract text with layout preservation.
  • Extract complex tables directly into Pandas DataFrames for analysis.

💎 Quality Expectations

  • Legibility: Text must be readable at 100% zoom; avoid walls of dense text.
  • Polish: Maintain intentional visual design—consistent margins and color palettes.
  • Verification: Zero defects (black squares, clipped text) permitted in final output.
</instructions>