PDFTK - what a great tool! Source

1---
2title: 'PDFTK - what a great tool!'
3date: '2015-01-19'
4published_at: '2015-01-19T08:06:00.001+11:00'
5tags: ['commands', 'pdf', 'pdftk']
6author: 'Gavin Jackson'
7excerpt: 'During the last week I have had to use a PDF manipulation tool called PDFTK. The first instance was to strip or replace pdf metadata (for work) and the second was to collate scanned pages from my prin...'
8updated_at: '2015-01-19T08:06:09.637+11:00'
9legacy_url: 'http://www.gavinj.net/2015/01/pdftk-what-great-tool.html'
10---
11
12[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuCnSwgKTUHV9D_iO7GveYe84VVLu0xs1dM4_CfBdvpwazEjr57gw5B47dVBBWAL4eI2zi7RtnvA5edfh9prbL1ehMVAc3UjixYggwxKRcR56Vitsk01IePl9V2sW_n77lNuEJ7VNS3io/s1600/pdftk3.jpg)](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuCnSwgKTUHV9D_iO7GveYe84VVLu0xs1dM4_CfBdvpwazEjr57gw5B47dVBBWAL4eI2zi7RtnvA5edfh9prbL1ehMVAc3UjixYggwxKRcR56Vitsk01IePl9V2sW_n77lNuEJ7VNS3io/s1600/pdftk3.jpg)
13
14During the last week I have had to use a PDF manipulation tool called PDFTK. The first instance was to strip or replace pdf metadata (for work) and the second was to collate scanned pages from my printer at home - it even supports the even pages in reverse format!
15
16My wife and I are trying to create a virtual filing system in Evernote.
17
18(From their website) PDFtk Server can:
19
20-
21
22Merge PDF Documents or Collate PDF Page Scans
23
24-
25
26Split PDF Pages into a New Document
27
28-
29
30Rotate PDF Documents or Pages
31
32-
33
34Decrypt Input as Necessary (Password Required)
35
36-
37
38Encrypt Output as Desired
39
40-
41
42Fill PDF Forms with X/FDF Data and/or Flatten Forms
43
44-
45
46Generate FDF Data Stencils from PDF Forms
47
48-
49
50Apply a Background Watermark or a Foreground Stamp
51
52-
53
54Report PDF Metrics, Bookmarks and Metadata
55
56-
57
58Add/Update PDF Bookmarks or Metadata
59
60-
61
62Attach Files to PDF Pages or the PDF Document
63
64-
65
66Unpack PDF Attachments
67
68-
69
70Burst a PDF Document into Single Pages
71
72-
73
74Uncompress and Re-Compress Page Streams
75
76-
77
78Repair Corrupted PDF (Where Possible)
79
80PDFtk Server does not require Adobe Acrobat or Reader, and it runs on Windows, Mac OS X and Linux.
81
82So I have a pretty standard scanner (an EPSON Artisan 837), it has a document feeder but only scans one side at a time, so when you run it through the first time you have odd pages, turn the bundle over, scan it and you have a bundle of even pages (in reverse order). This simple command collates them:
83
84pdftk A=odd_pages.pdf B=even_pages.pdf shuffle A Bend-1 output collated_pages.pdf
85
86if the even pages are in normal order, it's even easier:
87
88pdftk A=odd_pages.pdf B=even_pages.pdf shuffle A B output collated_pages.pdf
89
90**Question: Does anyone out there know if there is a python library for PDFTK (or equivalent)?**
91
92**References:** https://www.pdflabs.com/blog/how-to-collate-even-odd-scanned-pages/ https://www.pdflabs.com/tools/pdftk-server/
93
94
95