pdftk-server
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePDFtk Server
PDFtk Server
PDFtk Server is a command-line tool for working with PDF documents. It can merge, split, rotate, encrypt, decrypt, watermark, stamp, fill forms, extract metadata, and manipulate PDFs in a variety of ways.
PDFtk Server是一款用于处理PDF文档的命令行工具。它可以合并、拆分、旋转、加密、解密、添加水印、加盖图章、填充表单、提取元数据,并以多种方式操作PDF。
When to Use This Skill
何时使用本技能
- Merging or joining multiple PDF files into one
- Splitting or bursting a PDF into individual pages
- Rotating PDF pages
- Encrypting or decrypting PDF files
- Filling PDF form fields from FDF/XFDF data
- Applying background watermarks or foreground stamps
- Extracting PDF metadata, bookmarks, or form field information
- Repairing corrupted PDF files
- Attaching or extracting files embedded in PDFs
- Removing specific pages from a PDF
- Collating separately scanned even/odd pages
- Compressing or decompressing PDF page streams
- 将多个PDF文件合并为一个
- 将PDF拆分为单独的页面
- 旋转PDF页面
- 加密或解密PDF文件
- 从FDF/XFDF数据填充PDF表单字段
- 添加背景水印或前景图章
- 提取PDF元数据、书签或表单字段信息
- 修复损坏的PDF文件
- 附加或提取PDF中嵌入的文件
- 从PDF中删除特定页面
- 整理分开扫描的奇偶页
- 压缩或解压缩PDF页面流
Prerequisites
前提条件
- PDFtk Server must be installed on the system
- Windows:
winget install --id PDFLabs.PDFtk.Server - macOS:
brew install pdftk-java - Linux (Debian/Ubuntu):
sudo apt-get install pdftk - Linux (Red Hat/Fedora):
sudo dnf install pdftk
- Windows:
- Access to a terminal or command prompt
- Verify installation by running
pdftk --version
- 系统上必须安装PDFtk Server
- Windows:
winget install --id PDFLabs.PDFtk.Server - macOS:
brew install pdftk-java - Linux (Debian/Ubuntu):
sudo apt-get install pdftk - Linux (Red Hat/Fedora):
sudo dnf install pdftk
- Windows:
- 可访问终端或命令提示符
- 通过运行验证安装
pdftk --version
Step-by-Step Workflows
分步操作流程
Merge Multiple PDFs
合并多个PDF
bash
pdftk file1.pdf file2.pdf cat output merged.pdfUsing handles for more control:
bash
pdftk A=file1.pdf B=file2.pdf cat A B output merged.pdfbash
pdftk file1.pdf file2.pdf cat output merged.pdf使用句柄实现更精准的控制:
bash
pdftk A=file1.pdf B=file2.pdf cat A B output merged.pdfSplit a PDF into Individual Pages
将PDF拆分为单独页面
bash
pdftk input.pdf burstbash
pdftk input.pdf burstExtract Specific Pages
提取特定页面
Extract pages 1-5 and 10-15:
bash
pdftk input.pdf cat 1-5 10-15 output extracted.pdf提取第1-5页和第10-15页:
bash
pdftk input.pdf cat 1-5 10-15 output extracted.pdfRemove Specific Pages
删除特定页面
Remove page 13:
bash
pdftk input.pdf cat 1-12 14-end output output.pdf删除第13页:
bash
pdftk input.pdf cat 1-12 14-end output output.pdfRotate Pages
旋转页面
Rotate all pages 90 degrees clockwise:
bash
pdftk input.pdf cat 1-endeast output rotated.pdf将所有页面顺时针旋转90度:
bash
pdftk input.pdf cat 1-endeast output rotated.pdfEncrypt a PDF
加密PDF
Set an owner password and a user password with 128-bit encryption (default):
bash
pdftk input.pdf output secured.pdf owner_pw mypassword user_pw userpass设置所有者密码和用户密码,采用128位加密(默认):
bash
pdftk input.pdf output secured.pdf owner_pw mypassword user_pw userpassDecrypt a PDF
解密PDF
Remove encryption using the known password:
bash
pdftk secured.pdf input_pw mypassword output unsecured.pdf使用已知密码移除加密:
bash
pdftk secured.pdf input_pw mypassword output unsecured.pdfFill a PDF Form
填充PDF表单
Populate form fields from an FDF file and flatten to prevent further edits:
bash
pdftk form.pdf fill_form data.fdf output filled.pdf flatten从FDF文件填充表单字段,并使用扁平化处理防止后续编辑:
bash
pdftk form.pdf fill_form data.fdf output filled.pdf flattenApply a Background Watermark
添加背景水印
Place a single-page PDF behind every page of the input (input should have transparency):
bash
pdftk input.pdf background watermark.pdf output watermarked.pdf将单页PDF作为背景放置在输入PDF的每一页之后(输入PDF需包含透明区域):
bash
pdftk input.pdf background watermark.pdf output watermarked.pdfStamp an Overlay
加盖前景图章
Place a single-page PDF on top of every page of the input:
bash
pdftk input.pdf stamp overlay.pdf output stamped.pdf将单页PDF作为前景覆盖在输入PDF的每一页之上:
bash
pdftk input.pdf stamp overlay.pdf output stamped.pdfExtract Metadata
提取元数据
Export bookmarks, page metrics, and document information:
bash
pdftk input.pdf dump_data output metadata.txt导出书签、页面指标和文档信息:
bash
pdftk input.pdf dump_data output metadata.txtRepair a Corrupted PDF
修复损坏的PDF
Pass a broken PDF through pdftk to attempt automatic repair:
bash
pdftk broken.pdf output fixed.pdf将损坏的PDF通过pdftk处理,尝试自动修复:
bash
pdftk broken.pdf output fixed.pdfCollate Scanned Pages
整理扫描页面
Interleave separately scanned even and odd pages:
bash
pdftk A=even.pdf B=odd.pdf shuffle A B output collated.pdf交错合并分开扫描的偶数页和奇数页:
bash
pdftk A=even.pdf B=odd.pdf shuffle A B output collated.pdfTroubleshooting
故障排除
| Issue | Solution |
|---|---|
| Verify installation; check that pdftk is in your system PATH |
| Cannot decrypt PDF | Ensure you are providing the correct owner or user password via |
| Output file is empty or corrupt | Check input file integrity; try running |
| Form fields not visible after fill | Use the |
| Watermark not appearing | Ensure the input PDF has transparent regions; use |
| Permission denied errors | Check file permissions on input and output paths |
| 问题 | 解决方案 |
|---|---|
| 验证安装情况;检查pdftk是否在系统PATH中 |
| 无法解密PDF | 确保通过 |
| 输出文件为空或损坏 | 检查输入文件的完整性;先尝试运行 |
| 填充后表单字段不可见 | 使用 |
| 水印未显示 | 确保输入PDF包含透明区域;对于不透明覆盖层,使用 |
| 权限被拒绝错误 | 检查输入和输出路径的文件权限 |
References
参考资料
Bundled reference documents in the folder:
references/- pdftk-man-page.md - Complete manual reference with all operations, options, and syntax
- pdftk-cli-examples.md - Practical command-line examples for common tasks
- download.md - Installation and download instructions for all platforms
- pdftk-server-license.md - PDFtk Server licensing information
- third-party-materials.md - Third-party library licenses
references/- pdftk-man-page.md - 包含所有操作、选项和语法的完整手册参考
- pdftk-cli-examples.md - 常见任务的实用命令行示例
- download.md - 全平台的安装和下载说明
- pdftk-server-license.md - PDFtk Server许可信息
- third-party-materials.md - 第三方库许可信息