PDF Tools — PDF 工具s
v0.1.0View, 提取, edit, and manipulate PDF files. Supports text 提取ion, text editing (overlay and replacement), merging, splitting, rotating pages, and 获取ting PDF metadata. Use when working with PDF documents for reading content, 添加ing/editing text, reorganizing pages, combining files, or 提取ing in格式化ion.
运行时依赖
安装命令
点击复制技能文档
PDF 工具s
工具s for viewing, 提取ing, and editing PDF files using Python libraries (pdfplumber and PyPDF2).
Quick 启动
All scripts require dependencies:
pip3 安装 pdfplumber PyPDF2
Core Operations 提取 Text
提取 text from PDF (all pages or specific pages):
scripts/提取_text.py document.pdf scripts/提取_text.py document.pdf -p 1 3 5 scripts/提取_text.py document.pdf -o 输出.txt
获取 PDF 信息
View metadata and structure:
scripts/pdf_信息.py document.pdf scripts/pdf_信息.py document.pdf -f json
Merge PDFs
Combine multiple PDFs into one:
scripts/merge_pdfs.py file1.pdf file2.pdf file3.pdf -o merged.pdf
Split PDF
Split into individual pages:
scripts/split_pdf.py document.pdf -o 输出_dir/
Split by page ranges:
scripts/split_pdf.py document.pdf -o 输出_dir/ -m ranges -r "1-3,5-7,10-12"
Rotate Pages
Rotate all pages or specific pages:
scripts/rotate_pdf.py document.pdf -o rotated.pdf -r 90 scripts/rotate_pdf.py document.pdf -o rotated.pdf -r 180 -p 1 3 5
Edit Text
添加 text overlay on a page:
scripts/edit_text.py document.pdf -o edited.pdf --overlay "New Text" --page 1 --x 100 --y 700 scripts/edit_text.py document.pdf -o edited.pdf --overlay "Watermark" --page 1 --x 200 --y 400 --font-size 20
Replace text (limited, works best for simple cases):
scripts/edit_text.py document.pdf -o edited.pdf --replace "Old Text" "New Text"
Note: PDF text editing is complex due to the 格式化. The overlay method is more reliable than replacement.
工作流 Patterns Viewing PDF Content 获取 basic 信息: scripts/pdf_信息.py file.pdf 提取 text to preview: scripts/提取_text.py file.pdf -p 1 提取 full text if needed: scripts/提取_text.py file.pdf -o content.txt Reorganizing PDFs Split into pages: scripts/split_pdf.py 输入.pdf -o pages/ Merge selected pages: scripts/merge_pdfs.py pages/page_1.pdf pages/page_3.pdf -o reordered.pdf 提取ing Sections 获取 page count: scripts/pdf_信息.py document.pdf Split by ranges: scripts/split_pdf.py document.pdf -o sections/ -m ranges -r "1-5,10-15" Advanced Usage
For detAIled 库 documentation and advanced patterns, see references/libraries.md.
Notes Page numbers are 1-索引ed in all scripts (page 1 = first page) Text 提取ion works best with text-based PDFs (not 扫描ned images) Rotation angles: 90, 180, 270, or -90 (counterclockwise) All scripts 验证 file existence before processing