本文へスキップ
Skillpedia
PDF・Word・スライド7.8k · #12938

pdf-to-report-workflow

できること

このスキルは、既存のPDFを読んで、コマンドラインのツールだけで新しいPDFレポートを作るための、一連の流れです。コンテナや最小限の環境で、PythonのPDFライブラリがない人向けです。

使う場面

  • ✓既存のPDFから内容を取り出して、新しいPDFレポートを作る必要があるとき。
  • ✓複数のPDFの内容を、一つのレポートにまとめたいとき。
  • ✓PyPDF2やreportlabが入っていない、または追加できないとき。

スキルのリンク

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-cli-enhanced-657992/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-cli-enhanced-657992/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“この3つのPDFの内容を、一つの新しいレポートのPDFにまとめてください。ここではコマンドラインツールしか使えません。”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIは使えるツールを確認し、pdfinfoでメタデータを読み、pdftotextでテキストを取り出し、内容を組み立ててから、pandocやps2pdfなどのツールで最終的なPDFを作ります。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

PDF-to-Report Generation Workflow

This skill provides a complete end-to-end workflow for processing PDF documents: extracting content from source PDFs, assembling report data, and generating new PDF output files—all using command-line tools when Python libraries are unavailable.

When to Use This Skill

  • Need to extract text/content from existing PDFs
  • Need to create new PDF reports from extracted data
  • Need to combine multiple PDF sources into a single report
  • PyPDF2, reportlab, or similar Python PDF libraries are unavailable
  • Working in minimal/containerized environments

Core Tools

Extraction Tools (poppler-utils)

1. pdfinfo - Extract PDF Metadata

# Get full PDF info
pdfinfo document.pdf

# Get only page count
pdfinfo document.pdf | grep Pages

# Extract page count as a number
pdfinfo document.pdf | grep Pages | awk '{print $2}'

Key metadata fields:

  • Pages: Number of pages in the PDF
  • Title: Document title
  • Author: Document author
  • CreationDate: When the PDF was created
  • ModDate: Last modification date

2. pdftotext - Extract Text Content

# Extract all text to stdout
pdftotext document.pdf -

# Extract text to a file
pdftotext document.pdf output.txt

# Extract text from specific page range
pdftotext -f 1 -l 3 document.pdf output.txt

# Preserve layout (rough formatting)
pdftotext -layout document.pdf output.txt

Generation Tools (Choose based on availability)

1. enscript + ps2pdf - Text to PDF (Recommended)

Convert plain text to PDF via PostScript:

# Install if needed
apt-get install -y enscript ghostscript

# Convert text file to PDF
enscript -B -o output.ps input.txt && ps2pdf output.ps output.pdf

# One-liner
enscript -B input.txt -o - | ps2pdf - output.pdf

Options:

  • -B: No borders
  • -o: Output file (- for stdout)
  • -f: Font specification (e.g., -fCourier10)

2. wkhtmltopdf - HTML to PDF

Convert HTML to PDF with full formatting support:

# Install if needed
apt-get install -y wkhtmltopdf

# Convert HTML file to PDF
wkhtmltopdf input.html output.pdf

# Convert from stdin
echo "<html><body><h1>Report</h1></body></html>" | wkhtmltopdf - output.pdf

# With options for better quality
wkhtmltopdf --page-size A4 --margin-top 25mm input.html output.pdf

3. libreoffice - Document Conversion

Convert various document formats to PDF:

# Install if needed
apt-get install -y libreoffice-writer

# Convert to PDF (headless mode)
libreoffice --headless --convert-to pdf input.docx
libreoffice --headless --convert-to pdf input.odt
libreoffice --headless --convert-to pdf input.txt

4. pandoc - Universal Document Converter

Convert between many formats including PDF:

# Install if needed
apt-get install -y pandoc texlive-latex-base

# Convert markdown to PDF
pandoc input.md -o output.pdf

# Convert text to PDF
pandoc input.txt -o output.pdf

# With custom template
pandoc input.md --template=template.tex -o output.pdf

5. pdftk - PDF Manipulation

Merge, split, or modify existing PDFs:

# Install if needed
apt-get install -y pdftk

# Merge multiple PDFs
pdftk file1.pdf file2.pdf file3.pdf cat output merged.pdf

# Extract pages
pdftk input.pdf cat 1-3 output extracted.pdf

# Split into individual pages
pdftk input.pdf burst

Complete Workflow

Phase 1: Check Tool Availability

# Check extraction tools
which pdfinfo || echo "pdfinfo not found"
which pdftotext || echo "pdftotext not found"

# Check generation tools (at least one should be available)
which enscript || echo "enscript not found"
which wkhtmltopdf || echo "wkhtmltopdf not found"
which libreoffice || echo "libreoffice not found"
which pandoc || echo "pandoc not found"

Phase 2: Install Missing Tools

# Debian/Ubuntu - Full installation
apt-get update && apt-get install -y poppler-utils enscript ghostscript

# Or install wkhtmltopdf instead
apt-get install -y poppler-utils wkhtmltopdf

# Or install pandoc for markdown-based reports
apt-get install -y poppler-utils pandoc texlive-latex-base

Phase 3: Extract Content from Source PDFs

# Create working directory
mkdir -p workdir/extracted
cd workdir

# Extract text from each source PDF
for pdf in ../source_pdfs/*.pdf; do
    filename=$(basename "$pdf" .pdf)
    pdftotext -layout "$pdf" "extracted/${filename}.txt"
    echo "Extracted: $filename"
done

# Verify extraction
for txt in ext
よくある質問

ページ数を読むツールは?

ページ数などのメタデータを報告するpdfinfoです。

テキストを取り出すツールは?

すべてのテキストやページの範囲を取り出せるpdftotextです。

最終的なPDFを作るツールは?

インストールされているものに応じて、pandoc、wkhtmltopdf、enscriptとps2pdfなどの選択肢をガイドは挙げています。

詳細

作者による元の説明

Complete PDF workflow: extract content from source PDFs and generate new PDF reports using command-line tools

repo: HKUDS/AgentPilot

人気

GitHubのスター
7.8k
ランキング
#12938
ライセンス
MIT
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル