Skip to content
Back to skills

Pdf

ASecurity

读取与处理 PDF——提取文本/表格、合并拆分、提取指定页。当用户涉及 PDF 文件处理时使用。需要本机 Python + pypdf / pdfplumber。

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 6, 2026
ai-agentspythonshellbash

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 6, 2026

npx -y skills add Ducktang123/claude-code-deepseek --skill pdf --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pdf?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pdf
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ducktang123-pdf/badge)](https://www.skillsdirectory.com/skills/ducktang123-pdf)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pdf
description: 读取与处理 PDF——提取文本/表格、合并拆分、提取指定页。当用户涉及 PDF 文件处理时使用。需要本机 Python + pypdf / pdfplumber。
---

# PDF 处理

用 Python 处理 PDF。文本/表格提取用 `pdfplumber`,页面操作(合并/拆分/提取页)用 `pypdf`。通过 Bash/PowerShell 运行脚本。

## 前置
依赖库:`pypdf`、`pdfplumber`(安装包已自动装好;缺失则 `pip install pypdf pdfplumber -i https://pypi.tuna.tsinghua.edu.cn/simple`)。

## 常见任务

### 提取文本
```python
import pdfplumber
with pdfplumber.open("文件.pdf") as pdf:
    for i, page in enumerate(pdf.pages, 1):
        print(f"--- 第 {i} 页 ---")
        print(page.extract_text() or "")
```

### 提取表格
```python
import pdfplumber
with pdfplumber.open("文件.pdf") as pdf:
    for page in pdf.pages:
        for table in page.extract_tables():
            for row in table:
                print(row)
```

### 合并 / 拆分 / 提取页
```python
from pypdf import PdfReader, PdfWriter
# 合并
w = PdfWriter()
for f in ["a.pdf", "b.pdf"]:
    for p in PdfReader(f).pages: w.add_page(p)
with open("合并.pdf", "wb") as out: w.write(out)
# 提取第 1-3 页
r = PdfReader("文件.pdf"); w = PdfWriter()
for p in r.pages[0:3]: w.add_page(p)
with open("前三页.pdf", "wb") as out: w.write(out)
```

## 原则
- 扫描件(图片型 PDF)提不出文字,需要 OCR——遇到时如实告诉用户。
- 表格结构复杂时,先打印看清结构再处理。
- 处理完告诉用户输出文件路径。

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…