跳到正文
cccskills
免费在 GitHub 公开中文介绍

pdf

用于提取PDF中的文字、表格和图片,合并、拆分或旋转页面,创建文档并填写表单。还支持扫描文档文字识别,以及添加或解除密码保护。

原文查看原文说明

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

AI 评分80分/ 100查看安装方法

适用场景

  • 将PDF表格提取到Excel
  • 合并资料或提取所需页面
  • 识别扫描PDF中的文字
  • 创建PDF并填写表单

中文介绍

功能

从PDF中提取文字、表格和图片,合并多个文件,拆分或旋转页面,添加水印,以及创建新PDF。还可填写表单,添加或解除密码保护。对于扫描PDF,可通过OCR识别图片中的文字,使文档能够搜索。介绍中也包含将提取的表格汇总为Excel文件的示例。

适用场景

适合将多份资料合为一份、只保留所需页面,或重新利用PDF中的表格。也可用于转录纸质资料扫描件中的文字,以及创建在多个页面上排布文字的PDF。

使用示例

  • “提取这个PDF中的表格,汇总到Excel文件中。”
  • “合并这些PDF,并调整第一页的方向。”
  • “识别这份扫描PDF中的文字。”

注意事项

根据任务使用pypdf、pdfplumber、reportlab等Python库,或qpdf等外部工具。OCR示例使用pytesseract和pdf2image。表单填写部分需参阅FORMS.md。许可采用专有条款,详情见LICENSE.txt。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

客观评估

AI 仅根据 SKILL.md 的内容,从 4 个方面进行了评估。星标数和热度不计入评估。

指令清晰度能否看出何时使用、做什么
A良好说明明确列出PDF提取、合并、拆分和创建等使用场景与操作。
步骤具体性步骤、输入输出和示例是否具体
A良好提供合并、拆分的代码,以及将表格导出为Excel的具体示例。
安全性发送数据、删除文件、执行命令等是否有说明
B部分不足示例以wb模式保存文件,可能覆盖已有文件,但未说明事前确认步骤。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足提供OCR库的安装命令,但未提供全部外部工具的安装步骤。

总分按每项 A=25 分、B=15 分、C=5 分相加。 由 AI(OpenAI Codex)于 2026年10月20日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

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

包含的文件(12)

  • SKILL.md7.9 KB
  • forms.md11.6 KB
  • LICENSE.txt1.4 KB
  • reference.md16.3 KB
  • scripts/check_bounding_boxes.py2.7 KB
  • scripts/check_fillable_fields.py268 B
  • scripts/convert_pdf_to_images.py1008 B
  • scripts/create_validation_image.py1.2 KB
  • scripts/extract_form_field_info.py4.2 KB
  • scripts/extract_form_structure.py3.9 KB
  • scripts/fill_fillable_fields.py3.7 KB
  • scripts/fill_pdf_form_with_annotations.py3.2 KB

SKILL.md(原文)

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

PDF Processing Guide

Overview

This guide covers essential PDF processing operations using Python libraries and command-line tools. For advanced features, JavaScript libraries, and detailed examples, see REFERENCE.md. If you need to fill out a PDF form, read FORMS.md and follow its instructions.

Quick Start

from pypdf import PdfReader, PdfWriter

# Read a PDF
reader = PdfReader("document.pdf")
print(f"Pages: {len(reader.pages)}")

# Extract text
text = ""
for page in reader.pages:
    text += page.extract_text()

Python Libraries

pypdf - Basic Operations

Merge PDFs

from pypdf import PdfWriter, PdfReader

writer = PdfWriter()
for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
    reader = PdfReader(pdf_file)
    for page in reader.pages:
        writer.add_page(page)

with open("merged.pdf", "wb") as output:
    writer.write(output)

Split PDF

reader = PdfReader("input.pdf")
for i, page in enumerate(reader.pages):
    writer = PdfWriter()
    writer.add_page(page)
    with open(f"page_{i+1}.pdf", "wb") as output:
        writer.write(output)

Extract Metadata

reader = PdfReader("document.pdf")
meta = reader.metadata
print(f"Title: {meta.title}")
print(f"Author: {meta.author}")
print(f"Subject: {meta.subject}")
print(f"Creator: {meta.creator}")

Rotate Pages

reader = PdfReader("input.pdf")
writer = PdfWriter()

page = reader.pages[0]
page.rotate(90)  # Rotate 90 degrees clockwise
writer.add_page(page)

with open("rotated.pdf", "wb") as output:
    writer.write(output)

pdfplumber - Text and Table Extraction

Extract Text with Layout

import pdfplumber

with pdfplumber.open("document.pdf") as pdf:
    for page in pdf.pages:
        text = page.extract_text()
        print(text)

Extract Tables

with pdfplumber.open("document.pdf") as pdf:
    for i, page in enumerate(pdf.pages):
        tables = page.extract_tables()
        for j, table in enumerate(tables):
            print(f"Table {j+1} on page {i+1}:")
            for row in table:
                print(row)

Advanced Table Extraction

import pandas as pd

with pdfplumber.open("document.pdf") as pdf:
    all_tables = []
    for page in pdf.pages:
        tables = page.extract_tables()
        for table in tables:
            if table:  # Check if table is not empty
                df = pd.DataFrame(table[1:], columns=table[0])
                all_tables.append(df)

# Combine all tables
if all_tables:
    combined_df = pd.concat(all_tables, ignore_index=True)
    combined_df.to_excel("extracted_tables.xlsx", index=False)

reportlab - Create PDFs

Basic PDF Creation

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

c = canvas.Canvas("hello.pdf", pagesize=letter)
width, height = letter

# Add text
c.drawString(100, height - 100, "Hello World!")
c.drawString(100, height - 120, "This is a PDF created with reportlab")

# Add a line
c.line(100, height - 140, 400, height - 140)

# Save
c.save()

Create PDF with Multiple Pages

from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet

doc = SimpleDocTemplate("report.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = []

# Add content
title = Paragraph("Report Title", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))

body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())

# Page 2
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Content for page 2", styles['Normal']))

# Build PDF
doc.build(story)

Subscripts and Superscripts

IMPORTANT: Never use Unicode subscript/superscript characters (₀₁₂₃₄₅₆₇₈₉, ⁰¹²³⁴⁵⁶⁷⁸⁹) in ReportLab PDFs. The built-in fonts do not include these glyphs, causing them to render as solid black boxes.

Instead, use ReportLab's XML markup tags in Paragraph objects:

from reportlab.platypus import Paragraph
from reportlab.lib.styles import getSampleStyleSheet

styles = getSampleStyleSheet()

# Subscripts: use <sub> tag
chemical = Paragraph("H<sub>2</sub>O", styles['Normal'])

# Superscripts: use <super> tag
squared = Paragraph("x<super>2</super> + y<super>2</super>", styles['Normal'])

For canvas-drawn text (not Paragraph objects), manually adjust font the size and position rather than using Unicode subscripts/superscripts.

Command-Line Tools

pdftotext (poppler-utils)

# Extract text
pdftotext input.pdf output.txt

# Extract text preserving layout
pdftotext -layout input.pdf output.txt

# Extract specific pages
pdftotext -f 1 -l 5 input.pdf output.txt  # Pages 1-5

qpdf

# Merge PDFs
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf

# Split pages
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
qpdf input.pdf --pages . 6-10 -- pages6-10.pdf

# Rotate pages
qpdf input.pdf output.pdf --rotate=+90:1  # Rotate page 1 by 90 degrees

# Remove password
qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf

pdftk (if available)

# Merge
pdftk file1.pdf file2.pdf cat output merged.pdf

# Split
pdftk input.pdf burst

# Rotate
pdftk input.pdf rotate 1east output rotated.pdf

Common Tasks

Extract Text from Scanned PDFs

# Requires: pip install pytesseract pdf2image
import pytesseract
from pdf2image import convert_from_path

# Convert PDF to images
images = convert_from_path('scanned.pdf')

# OCR each page
text = ""
for i, image in enumerate(images):
    text += f"Page {i+1}:\n"
    text += pytesseract.image_to_string(image)
    text += "\n\n"

print(text)

Add Watermark

from pypdf import PdfReader, PdfWriter

# Create watermark (or load existing)
watermark = PdfReader("watermark.pdf").pages[0]

# Apply to all pages
reader = PdfReader("document.pdf")
writer = PdfWriter()

for page in reader.pages:
    page.merge_page(watermark)
    writer.add_page(page)

with open("watermarked.pdf", "wb") as output:
    writer.write(output)

Extract Images

# Using pdfimages (poppler-utils)
pdfimages -j input.pdf output_prefix

# This extracts all images as output_prefix-000.jpg, output_prefix-001.jpg, etc.

Password Protection

from pypdf import PdfReader, PdfWriter

reader = PdfReader("input.pdf")
writer = PdfWriter()

for page in reader.pages:
    writer.add_page(page)

# Add password
writer.encrypt("userpassword", "ownerpassword")

with open("encrypted.pdf", "wb") as output:
    writer.write(output)

Quick Reference

TaskBest ToolCommand/Code
Merge PDFspypdfwriter.add_page(page)
Split PDFspypdfOne page per file
Extract textpdfplumberpage.extract_text()
Extract tablespdfplumberpage.extract_tables()
Create PDFsreportlabCanvas or Platypus
Command line mergeqpdfqpdf --empty --pages ...
OCR scanned PDFspytesseractConvert to image first
Fill PDF formspdf-lib or pypdf (see FORMS.md)See FORMS.md

Next Steps

  • For advanced pypdfium2 usage, see REFERENCE.md
  • For JavaScript libraries (pdf-lib), see REFERENCE.md
  • If you need to fill out a PDF form, follow the instructions in FORMS.md
  • For troubleshooting guides, see REFERENCE.md

评价

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

评论

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

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

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

0 / 1000 字

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

同一仓库的技能

academy-guide

免费有简介AI 评分 100分

根据学习 Claude 用法或团队引入需求,查看 Claude Academy 的课程、教程和应用实例,提供符合学习目标的资料。

  • 寻找 Claude 入门资料
  • 学习 Claude 的特定功能
  • 为团队引入 Claude 选择教材
anthropics/skills18.2万2026年10月10日 更新

algorithmic-art

免费有简介AI 评分 90分

使用p5.js,通过粒子运动和数学规则创作原创生成艺术。作品配有交互界面,可调整数值、比较变化,使用种子复现相同条件下的画面,并保存为PNG。

  • 用代码创作原创艺术
  • 尝试粒子与流动效果
  • 调整种子和参数比较变化
anthropics/skills18.2万2026年10月10日 更新

brand-guidelines

免费有简介AI 评分 90分

将Anthropic的品牌配色和字体应用于制作内容,统一标题与正文的字体,根据背景调整文字颜色,并为图形设置一致的强调色。

  • 按Anthropic品牌配色整理文档
  • 统一标题和正文的字体
  • 根据深浅背景调整文字颜色
anthropics/skills18.2万2026年10月10日 更新

canvas-design

免费有简介AI 评分 90分

从配色、形状、留白和构图等设计方向入手,制作原创海报与静态艺术作品,以少量文字表达主题,输出 PNG 或 PDF,并附上设计理念文档。

  • 围绕主题制作原创海报
  • 创作少量文字的抽象艺术作品
  • 同时保存作品与设计理念
anthropics/skills18.2万2026年10月10日 更新

claude-api

免费有简介AI 评分 70分

依据按编程语言分类的资料,协助开发和维护Claude应用。涵盖官方SDK调用、工具集成、模型迁移、费用检查、提示词审查和评估流程。

  • 在应用中接入Claude API
  • 开发使用自定义工具的智能体
  • 为现有Claude集成迁移模型
anthropics/skills18.2万2026年10月10日 更新

discernment-nudge

免费有简介AI 评分 100分

在AI的建议、计划、估算或分析后附上两三个简短问题,帮助用户在行动前检查数字、逻辑与缺失信息。问题紧扣回答中的具体内容,可直接向代理追问。

  • 检查费用与交付时间估算的前提
  • 审视推荐计划的依据
  • 检查提案或邮件草稿缺失的信息
anthropics/skills18.2万2026年10月10日 更新

查看 anthropics 的全部技能

报告此技能的问题