1
---
2
name: pdftk-server
3
description: '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.'
4
---
5
6
# PDFtk Server
7
8
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.
9
10
## When to Use This Skill
11
12
- Merging or joining multiple PDF files into one
13
- Splitting or bursting a PDF into individual pages
14
- Rotating PDF pages
15
- Encrypting or decrypting PDF files
16
- Filling PDF form fields from FDF/XFDF data
17
- Applying background watermarks or foreground stamps
18
- Extracting PDF metadata, bookmarks, or form field information
19
- Repairing corrupted PDF files
20
- Attaching or extracting files embedded in PDFs
21
- Removing specific pages from a PDF
22
- Collating separately scanned even/odd pages
23
- Compressing or decompressing PDF page streams
24
25
## Prerequisites
26
27
- PDFtk Server must be installed on the system
28
- **Windows**: `winget install --id PDFLabs.PDFtk.Server`
29
- **macOS**: `brew install pdftk-java`
30
- **Linux (Debian/Ubuntu)**: `sudo apt-get install pdftk`
31
- **Linux (Red Hat/Fedora)**: `sudo dnf install pdftk`
32
- Access to a terminal or command prompt
33
- Verify installation by running `pdftk --version`
34
35
## Step-by-Step Workflows
36
37
### Merge Multiple PDFs
38
39
```bash
40
pdftk file1.pdf file2.pdf cat output merged.pdf
41
```
42
43
Using handles for more control:
44
45
```bash
46
pdftk A=file1.pdf B=file2.pdf cat A B output merged.pdf
47
```
48
49
### Split a PDF into Individual Pages
50
51
```bash
52
pdftk input.pdf burst
53
```
54
55
### Extract Specific Pages
56
57
Extract pages 1-5 and 10-15:
58
59
```bash
60
pdftk input.pdf cat 1-5 10-15 output extracted.pdf
61
```
62
63
### Remove Specific Pages
64
65
Remove page 13:
66
67
```bash
68
pdftk input.pdf cat 1-12 14-end output output.pdf
69
```
70
71
### Rotate Pages
72
73
Rotate all pages 90 degrees clockwise:
74
75
```bash
76
pdftk input.pdf cat 1-endeast output rotated.pdf
77
```
78
79
### Encrypt a PDF
80
81
Set an owner password and a user password with 128-bit encryption (default):
82
83
```bash
84
pdftk input.pdf output secured.pdf owner_pw mypassword user_pw userpass
85
```
86
87
### Decrypt a PDF
88
89
Remove encryption using the known password:
90
91
```bash
92
pdftk secured.pdf input_pw mypassword output unsecured.pdf
93
```
94
95
### Fill a PDF Form
96
97
Populate form fields from an FDF file and flatten to prevent further edits:
98
99
```bash
100
pdftk form.pdf fill_form data.fdf output filled.pdf flatten
101
```
102
103
### Apply a Background Watermark
104
105
Place a single-page PDF behind every page of the input (input should have transparency):
106
107
```bash
108
pdftk input.pdf background watermark.pdf output watermarked.pdf
109
```
110
111
### Stamp an Overlay
112
113
Place a single-page PDF on top of every page of the input:
114
115
```bash
116
pdftk input.pdf stamp overlay.pdf output stamped.pdf
117
```
118
119
### Extract Metadata
120
121
Export bookmarks, page metrics, and document information:
122
123
```bash
124
pdftk input.pdf dump_data output metadata.txt
125
```
126
127
### Repair a Corrupted PDF
128
129
Pass a broken PDF through pdftk to attempt automatic repair:
130
131
```bash
132
pdftk broken.pdf output fixed.pdf
133
```
134
135
### Collate Scanned Pages
136
137
Interleave separately scanned even and odd pages:
138
139
```bash
140
pdftk A=even.pdf B=odd.pdf shuffle A B output collated.pdf
141
```
142
143
## Troubleshooting
144
145
| Issue | Solution |
146
|-------|----------|
147
| `pdftk` command not found | Verify installation; check that pdftk is in your system PATH |
148
| Cannot decrypt PDF | Ensure you are providing the correct owner or user password via `input_pw` |
149
| Output file is empty or corrupt | Check input file integrity; try running `pdftk input.pdf output repaired.pdf` first |
150
| Form fields not visible after fill | Use the `flatten` flag to merge fields into the page content |
151
| Watermark not appearing | Ensure the input PDF has transparent regions; use `stamp` for opaque overlays |
152
| Permission denied errors | Check file permissions on input and output paths |
153
154
## References
155
156
Bundled reference documents in the `references/` folder:
157
158
- [pdftk-man-page.md](references/pdftk-man-page.md) - Complete manual reference with all operations, options, and syntax
159
- [pdftk-cli-examples.md](references/pdftk-cli-examples.md) - Practical command-line examples for common tasks
160
- [download.md](references/download.md) - Installation and download instructions for all platforms
161
- [pdftk-server-license.md](references/pdftk-server-license.md) - PDFtk Server licensing information
162
- [third-party-materials.md](references/third-party-materials.md) - Third-party library licenses
163