pdf-report-workflow-cli
它能做什么
这项技能是一套只使用命令行的工作流程,用于从源文件制作 PDF 报告。它适合在容器或 CI 环境中工作、且没有 Python PDF 库的人。
适用场景
- ✓当环境中没有 Python PDF 库的时候。
- ✓当我在容器或 CI 任务中构建文档流程的时候。
- ✓当我需要把经过验证的 PDF 内容合并成一份新报告的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-cli-enhanced/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请用这个容器里的源 PDF 制作一份 PDF 报告。这里只安装了命令行工具,请使用这些工具。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会检查哪些 PDF 工具存在,验证源文件,提取其文字,组装报告,并用可用的工具生成输出 PDF。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
PDF Report Generation with Command-Line Tools
When working with PDFs in minimal/containerized environments where Python libraries may be unavailable, this skill provides a complete end-to-end workflow: verify source PDFs, extract content, assemble structured reports, and generate final PDF output.
When to Use This Skill
- Need to create new PDF reports from existing PDF sources
- Need to verify, extract, and combine PDF content
- Working in environments without Python PDF libraries
- Building document assembly pipelines in CI/CD or containers
Complete Workflow Overview
[Source PDFs] → [Verify] → [Extract] → [Assemble] → [Generate Output PDF]
Phase 1: Tool Availability Check
# Core extraction tools (from poppler-utils)
which pdfinfo && echo "✓ pdfinfo available" || echo "✗ pdfinfo missing"
which pdftotext && echo "✓ pdftotext available" || echo "✗ pdftotext missing"
# PDF generation tools (choose based on availability)
which pdftk && echo "✓ pdftk available (PDF merging)" || true
which wkhtmltopdf && echo "✓ wkhtmltopdf available (HTML→PDF)" || true
which pandoc && echo "✓ pandoc available (document conversion)" || true
which enscript && echo "✓ enscript available (text→PS)" || true
which ps2pdf && echo "✓ ps2pdf available (PS→PDF)" || true
Install Required Tools
# Debian/Ubuntu - Core tools
apt-get update && apt-get install -y poppler-utils
# Optional: PDF generation tools (choose based on needs)
apt-get install -y pdftk # PDF merging/manipulation
apt-get install -y wkhtmltopdf # HTML to PDF
apt-get install -y pandoc # Document conversion
apt-get install -y enscript ghostscript # Text to PDF pipeline
# RHEL/CentOS/Fedora
yum install -y poppler-utils pdftk ghostscript
# or
dnf install -y poppler-utils pdftk ghostscript
# macOS (with Homebrew)
brew install poppler pdftk ghostscript
brew install --cask wkhtmltopdf # GUI app, includes CLI
Phase 2: Verify Source PDFs
Check Page Count and Metadata
# Verify each source PDF exists and is readable
for pdf in source1.pdf source2.pdf source3.pdf; do
if [ ! -f "$pdf" ]; then
echo "ERROR: $pdf not found"
exit 1
fi
pages=$(pdfinfo "$pdf" | grep Pages | awk '{print $2}')
echo "$pdf: $pages pages"
done
Validate Content Presence
# Check that required sections exist in source documents
REQUIRED_TERMS=("checklist" "summary" "references")
for term in "${REQUIRED_TERMS[@]}"; do
if pdftotext source.pdf - | grep -qi "$term"; then
echo "✓ Found: $term"
else
echo "⚠ Missing: $term"
fi
done
Phase 3: Extract Content from Source PDFs
Extract Text to Temporary Files
# Create working directory
WORK_DIR=$(mktemp -d)
echo "Working directory: $WORK_DIR"
# Extract text from each source PDF
for i in source1.pdf source2.pdf source3.pdf; do
base=$(basename "$i" .pdf)
pdftotext -layout "$i" "$WORK_DIR/${base}.txt"
echo "Extracted: $i → ${base}.txt"
done
# Also extract metadata for reference
pdfinfo source1.pdf > "$WORK_DIR/source1_metadata.txt"
Extract Specific Sections (Optional)
# Extract only specific page ranges
pdftotext -f 1 -l 3 source1.pdf "$WORK_DIR/source1_pages1-3.txt"
# Extract and filter for specific content
pdftotext source1.pdf - | grep -A 10 "Summary" > "$WORK_DIR/summary_section.txt"
Phase 4: Assemble Report Content
Create Structured Report (Markdown Format)
REPORT_MD="$WORK_DIR/report.md"
cat > "$REPORT_MD" << 'REPORT_HEADER'
# New Case Creation Report
**Generated:** $(date '+%Y-%m-%d %H:%M:%S')
---
## Executive Summary
REPORT_HEADER
# Add content from extracted sources
echo "## Case Details" >> "$REPORT_MD"
echo "" >> "$REPORT_MD"
cat "$WORK_DIR/source1.txt" >> "$REPORT_MD"
echo "" >> "$REPORT_MD"
echo "## Supporting Documentation" >> "$REPORT_MD"
echo "" >> "$REPORT_MD"
cat "$WORK_DIR/source2.txt" >> "$REPORT_MD"
echo "" >> "$REPORT_MD"
echo "## References" >> "$REPORT_MD"
echo "" >> "$REPORT_MD"
cat "$WORK_DIR/source3.txt" >> "$REPORT_MD"
echo "Report assembled: $REPORT_MD"
Create HTML Report (Alternative for Better Formatting)
REPORT_HTML="$WORK_DIR/report.html"
cat > "$REPORT_HTML" << 'HTML_HEADER'
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Case Creation Report</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
h1 { color: #333; borde
常见问题
涉及哪些软件包?
指南依赖 poppler-utils 读取 PDF,并使用 pandoc 等工具生成输出。
为什么先检查工具?
指南会说明哪些工具存在,从而选用正确的途径。
它需要 Python 吗?
工作流程基于命令行工具构建,因此不需要 Python 库。
详情
作者的原始描述
Complete PDF workflow: verify, extract content, assemble reports, and generate output PDFs using command-line tools
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12939
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。