跳到正文
Skillpedia
PDF、Word 与幻灯片40k · #7315

pdftk-server

它能做什么

这个工具可以让你直接在电脑上处理 PDF 文件。你可以把多个 PDF 合并成一个,把 PDF 拆分成单独的页面,旋转页面,设置密码保护,填写表单,甚至修复损坏的 PDF。

适用场景

  • ✓当你需要把几份 PDF 文档合并成一个文件时。
  • ✓当你想把一个大型 PDF 拆分成一页一页的独立文件时。
  • ✓当你需要给 PDF 加上密码,或者去掉已有的密码时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/pdftk-server/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/pdftk-server/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“把这三个 PDF 合并成一个:“document1.pdf”、“document2.pdf”、“document3.pdf”。”

每周 5 个新技能,1 分钟读完。

工作原理

你在电脑上输入特定的命令,告诉工具要对 PDF 文件做什么操作。例如,要合并两个 PDF,你就输入一条命令,列出这些文件以及新文件的名称。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

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.

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

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
  • Access to a terminal or command prompt
  • Verify installation by running pdftk --version

Step-by-Step Workflows

Merge Multiple PDFs

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

Using handles for more control:

pdftk A=file1.pdf B=file2.pdf cat A B output merged.pdf

Split a PDF into Individual Pages

pdftk input.pdf burst

Extract Specific Pages

Extract pages 1-5 and 10-15:

pdftk input.pdf cat 1-5 10-15 output extracted.pdf

Remove Specific Pages

Remove page 13:

pdftk input.pdf cat 1-12 14-end output output.pdf

Rotate Pages

Rotate all pages 90 degrees clockwise:

pdftk input.pdf cat 1-endeast output rotated.pdf

Encrypt a PDF

Set an owner password and a user password with 128-bit encryption (default):

pdftk input.pdf output secured.pdf owner_pw mypassword user_pw userpass

Decrypt a PDF

Remove encryption using the known password:

pdftk secured.pdf input_pw mypassword output unsecured.pdf

Fill a PDF Form

Populate form fields from an FDF file and flatten to prevent further edits:

pdftk form.pdf fill_form data.fdf output filled.pdf flatten

Apply a Background Watermark

Place a single-page PDF behind every page of the input (input should have transparency):

pdftk input.pdf background watermark.pdf output watermarked.pdf

Stamp an Overlay

Place a single-page PDF on top of every page of the input:

pdftk input.pdf stamp overlay.pdf output stamped.pdf

Extract Metadata

Export bookmarks, page metrics, and document information:

pdftk input.pdf dump_data output metadata.txt

Repair a Corrupted PDF

Pass a broken PDF through pdftk to attempt automatic repair:

pdftk broken.pdf output fixed.pdf

Collate Scanned Pages

Interleave separately scanned even and odd pages:

pdftk A=even.pdf B=odd.pdf shuffle A B output collated.pdf

Troubleshooting

Issue Solution
pdftk command not found Verify installation; check that pdftk is in your system PATH
Cannot decrypt PDF Ensure you are providing the correct owner or user password via input_pw
Output file is empty or corrupt Check input file integrity; try running pdftk input.pdf output repaired.pdf first
Form fields not visible after fill Use the flatten flag to merge fields into the page content
Watermark not appearing Ensure the input PDF has transparent regions; use stamp for opaque overlays
Permission denied errors Check file permissions on input and output paths

References

Bundled reference documents in the references/ folder:

常见问题

什么是 “pdftk-server”?

它是一个安装在电脑上的程序,通过文本命令来完成各种 PDF 文件的处理工作。

我需要安装什么吗?

需要。你需要在电脑上安装 “PDFtk Server”。安装方法因你使用的是 Windows、macOS 还是 Linux 而有所不同。

我可以用它来编辑 PDF 里的文字吗?

不能直接编辑。这个工具用于整理、合并、拆分、加密或填写 PDF 中的表单,但不能修改 PDF 中已有的文字。

详情

作者的原始描述

Skill for using the command-line tool pdftk (PDFtk Server) for working with PDF files. Use when asked to merge PDFs, split PDFs, rotate pages, encrypt or decrypt PDFs, fill PDF forms, apply watermarks, stamp overlays, extract metadata, burst documents into pages, repair corrupted PDFs, attach or extract files, or perform any PDF manipulation from the command line.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7315
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能