跳到正文
cccskills
免费在 GitHub 公开

pdf

Extract text from PDFs, inspect page counts and document metadata, merge files, or split them into individual pages. Create PDFs from Markdown, HTML, or Python code, using the tools suited to each task.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Process PDF files - extract text, create PDFs, merge documents. Use when user asks to read PDF, create PDF, or work with PDF files.

查看安装方法

适用场景

  • Extracting text from a PDF
  • Combining several PDFs into one
  • Splitting a PDF into individual pages
  • Converting Markdown or HTML to PDF

包含的文件(1)

  • SKILL.md2.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

PDF Processing Skill

You now have expertise in PDF manipulation. Follow these workflows:

Reading PDFs

Option 1: Quick text extraction (preferred)

# Using pdftotext (poppler-utils)
pdftotext input.pdf -  # Output to stdout
pdftotext input.pdf output.txt  # Output to file

# If pdftotext not available, try:
python3 -c "
import fitz  # PyMuPDF
doc = fitz.open('input.pdf')
for page in doc:
    print(page.get_text())
"

Option 2: Page-by-page with metadata

import fitz  # pip install pymupdf

doc = fitz.open("input.pdf")
print(f"Pages: {len(doc)}")
print(f"Metadata: {doc.metadata}")

for i, page in enumerate(doc):
    text = page.get_text()
    print(f"--- Page {i+1} ---")
    print(text)

Creating PDFs

Option 1: From Markdown (recommended)

# Using pandoc
pandoc input.md -o output.pdf

# With custom styling
pandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=1in

Option 2: Programmatically

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello, PDF!")
c.save()

Option 3: From HTML

# Using wkhtmltopdf
wkhtmltopdf input.html output.pdf

# Or with Python
python3 -c "
import pdfkit
pdfkit.from_file('input.html', 'output.pdf')
"

Merging PDFs

import fitz

result = fitz.open()
for pdf_path in ["file1.pdf", "file2.pdf", "file3.pdf"]:
    doc = fitz.open(pdf_path)
    result.insert_pdf(doc)
result.save("merged.pdf")

Splitting PDFs

import fitz

doc = fitz.open("input.pdf")
for i in range(len(doc)):
    single = fitz.open()
    single.insert_pdf(doc, from_page=i, to_page=i)
    single.save(f"page_{i+1}.pdf")

Key Libraries

TaskLibraryInstall
Read/Write/MergePyMuPDFpip install pymupdf
Create from scratchReportLabpip install reportlab
HTML to PDFpdfkitpip install pdfkit + wkhtmltopdf
Text extractionpdftotextbrew install poppler / apt install poppler-utils

Best Practices

  1. Always check if tools are installed before using them
  2. Handle encoding issues - PDFs may contain various character encodings
  3. Large PDFs: Process page by page to avoid memory issues
  4. OCR for scanned PDFs: Use pytesseract if text extraction returns empty

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Design and build AI agents for business, research, operations, or creative work. Define essential actions and knowledge, start with a simple execution loop, and add progress tracking or separate child agents as needs emerge.

中文简介正在准备中。当前显示英语简介。

  • Designing an assistant for business tasks
  • Building a research agent
  • Choosing essential actions and knowledge
shareAI-lab/learn-claude-code7.9万2026年9月28日 更新

Review code for security flaws, bugs, performance problems, maintainability, and test quality. Produce structured feedback with issue locations, likely impact, suggested fixes, positive observations, and a recommendation on whether changes are ready to merge.

中文简介正在准备中。当前显示英语简介。

  • Reviewing a pull request before merging
  • Investigating bugs and edge cases
  • Checking security flaws and dependencies
shareAI-lab/learn-claude-code7.9万2026年9月28日 更新

Build MCP servers, which let Claude call external tools and read data through a shared protocol. Follow Python or TypeScript examples to implement tools, connect services, configure Claude, and test server behavior.

中文简介正在准备中。当前显示英语简介。

  • Adding custom tools to Claude
  • Connecting an external API
  • Reading database records or settings
shareAI-lab/learn-claude-code7.9万2026年9月28日 更新

查看 shareAI-lab 的全部技能

报告此技能的问题