agentleFS
Marnie0415Marnie0415/pi-skills/pdf-processing/SKILL.md

pdf-processing

Skill1 starsChanged 5 months agoMITView on GitHub

Extract text, merge, split, and manipulate PDF documents. Use when the user needs to process PDF files — extracting data, combining documents, adding watermarks, or converting to/from other formats.

  • Installs packages

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use pptx and deep-research.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • AnthropicSkill

    pptx

    Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

    Also in 3 projects that use this

  • NVIDIASkill

    deep-research

    Queue deep, multi-step research and analysis tasks to the DeepAgents worker. Supports execution depth presets, request-specific rubrics, SubAgent delegation, and RubricMiddleware cross-validation.

    Also in 3 projects that use this

The file

Files
SKILL.md

PDF 文档处理 Skill

在 Termux Android 上使用轻量工具处理 PDF 文件。

可用工具

方案 A: pdf-lib (Node.js 纯 JS, 推荐)

npm install pdf-lib

方案 B: Python + PyPDF2 / pypdf

pip install pypdf

方案 C: poppler (系统工具,Termux 可用)

pkg install poppler
# pdftotext, pdfinfo, pdfimages, pdfseparate, pdfunite

常见操作

1. 提取文本

# Python + pypdf
from pypdf import PdfReader
reader = PdfReader('input.pdf')
for page in reader.pages:
    print(page.extract_text())
# 系统工具 (poppler)
pdftotext input.pdf output.txt

2. 合并 PDF 文件

from pypdf import PdfWriter
writer = PdfWriter()
for pdf in ['file1.pdf', 'file2.pdf']:
    reader = PdfReader(pdf)
    for page in reader.pages:
        writer.add_page(page)
writer.write('merged.pdf')
pdfunite file1.pdf file2.pdf merged.pdf

3. 拆分 PDF (提取指定页)

reader = PdfReader('input.pdf')
writer = PdfWriter()
for i in range(start_page, end_page):  # 0-indexed
    writer.add_page(reader.pages[i])
writer.write('output.pdf')

4. 添加文字/水印

// Node.js + pdf-lib
import { PDFDocument, StandardFonts, rgb } from 'pdf-lib'
const doc = await PDFDocument.load(fs.readFileSync('input.pdf'))
const font = await doc.embedFont(StandardFonts.Helvetica)
const pages = doc.getPages()
const page = pages[0]
page.drawText('CONFIDENTIAL', { x: 50, y: 50, font, size: 48, color: rgb(0.8,0,0), opacity: 0.3 })
fs.writeFileSync('output.pdf', await doc.save())

5. 提取图片

pdfimages -j input.pdf images_output/

注意事项

  • 📐 处理中文 PDF 时,pypdf 提取中文文本可能乱码,优先用 pdf-lib
  • ⚠️ 扫描版 PDF(图片式)无法提取文本,需 OCR(用 tesseract)
  • 📏 合并大文件注意内存占用,逐页流式处理
  • 🔄 pdf-lib 的 save() 返回 Buffer,写入时用 fs.writeFileSync
  • 💾 操作前先备份原文件

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.