360 Secure SkillHub
360 安全技能中心

PDF Read/Write Toolkit

提供多个 Python 脚本,可读取 PDF 文本、按页提取、导出表格为 CSV/JSON、获取元数据,以及合并、拆分和从 HTML/Markdown 生成 PDF。依赖 pdfplumber、pypdf、weasyprint,按命令行方式调用。

droba07
droba07
热度 42.12
最近更新 2026-05-11 17:43:26
分类:效率依赖:代码执行 / 读写文件应用场景:文件转换 / 数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add pdf-rw-toolkit
Metadata
name
pdf
description
Read, extract, and generate PDF files. Use when user asks to read PDF content, extract text/tables, merge PDFs, fill forms, or generate PDFs from HTML/Markdown.
metadata
{"openclaw":{"requires":{"bins":["python3"],"pip":["pdfplumber","pypdf","weasyprint"]}}}

PDF Skill

Read, extract, analyze, and generate PDF documents.

Capabilities

  • Extract text from PDF (full or per-page)
  • Extract tables from PDF as CSV/JSON
  • Get metadata (title, author, pages, etc.)
  • Merge multiple PDFs into one
  • Split PDF by page ranges
  • Generate PDF from HTML or Markdown
  • Fill PDF forms

Scripts

All scripts are in scripts/ relative to this skill directory.

Read / Extract

# Extract all text
python3 scripts/pdf_read.py <file.pdf>

# Extract text from specific pages (1-indexed)
python3 scripts/pdf_read.py <file.pdf> --pages 1,3,5-10

# Extract tables as CSV
python3 scripts/pdf_read.py <file.pdf> --tables --format csv

# Extract tables as JSON
python3 scripts/pdf_read.py <file.pdf> --tables --format json

# Get PDF metadata and page count
python3 scripts/pdf_read.py <file.pdf> --info

Merge / Split

# Merge multiple PDFs
python3 scripts/pdf_merge.py output.pdf input1.pdf input2.pdf input3.pdf

# Split: extract specific pages
python3 scripts/pdf_split.py input.pdf output.pdf --pages 1,3,5-10

Generate

# Generate PDF from HTML file
python3 scripts/pdf_generate.py input.html output.pdf

# Generate PDF from HTML string
python3 scripts/pdf_generate.py --html "<h1>Hello</h1><p>World</p>" output.pdf

# Generate PDF from Markdown (converted to HTML first)
python3 scripts/pdf_generate.py input.md output.pdf

Usage Notes

  • For large PDFs, use --pages to limit extraction scope
  • Table extraction works best with well-structured tables; complex layouts may need manual cleanup
  • PDF generation via WeasyPrint supports CSS styling — pass a --css file for custom styles
  • All paths can be absolute or relative to the workspace