Skip to content
Skillpedia
PDF, Word & slides7.8k · #12938

pdf-to-report-workflow

What it does

This skill is an end-to-end way to read source PDFs and create a new PDF report with command line tools. It is for people in minimal or containerized setups where Python PDF libraries are unavailable.

When to use it

  • ✓When I need to pull content out of existing PDFs and make a new PDF report.
  • ✓When I need to combine several PDF sources into one report.
  • ✓When PyPDF2 or reportlab is not installed and I cannot add them.

Skill link

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

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-cli-enhanced-657992/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Combine the content of these three PDFs into one new report PDF. Only command line tools are available here.”

5 new skills a week. 1 minute to read.

How it works

The AI checks the available tools, reads metadata with pdfinfo, extracts text with pdftotext, assembles the content and then generates the final PDF with a tool such as pandoc or ps2pdf.

Technical content (original SKILL.md)

Original text by the author, straight from 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
FAQ

Which tool reads page counts?

pdfinfo, which reports the number of pages and other metadata.

Which tool gets the text?

pdftotext, which can extract all text or a range of pages.

Which tools make the final PDF?

The guide lists options such as pandoc, wkhtmltopdf and enscript with ps2pdf, depending on what is installed.

Details

Original description by the author

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

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#12938
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills