pdftk-notes/pdftk basic usage.md

76 lines
1.6 KiB
Markdown
Raw Normal View History

2021-09-09 00:30:42 +00:00
# Basic Usage
2021-09-07 22:50:40 +00:00
To merge (concatenate) pdfs:
2021-09-09 00:28:35 +00:00
$ pdftk inputs cat output newfile.pdf
2021-09-07 22:50:40 +00:00
To merge all pdfs:
2021-09-09 00:28:35 +00:00
$ pdftk *.pdf cat output newfile.pdf
2021-09-07 22:50:40 +00:00
To break a pdf into single page files:
2021-09-09 00:28:35 +00:00
$ pdftk input.pdf burst
2021-09-07 22:50:40 +00:00
To combine parts of two or more files, use handles:
2021-09-09 00:28:35 +00:00
$ pdftk A=firstfile.pdf B=secondfile.pdf cat A1-7 B1-5 A8 output newfile.pdf
2021-09-07 22:50:40 +00:00
2021-09-09 00:30:42 +00:00
# Editing Metadata
2021-09-07 22:50:40 +00:00
To edit metadata is a multistep process:
1) Dump the pdf metadata:
2021-09-09 00:35:56 +00:00
```
$ pdftk input.pdf dump_data metadata.txt
```
2021-09-07 22:50:40 +00:00
2) Edit the metadata (Geany appears to work), adding:
2021-09-09 00:28:35 +00:00
```
2021-09-07 22:50:40 +00:00
InfoBegin
InfoKey: Author
InfoValue: Kenneth John Odle
InfoBegin
InfoKey: Title
InfoValue: Journal #42
2021-09-09 00:30:42 +00:00
```
2021-09-07 22:50:40 +00:00
(For "Title" enter whatever you want to see in the document's title bar as you read it.)
3) Update the metadata in the pdf file:
2021-09-09 00:35:56 +00:00
```
$ pdft input.pdf update_info metadata.txt output.pdf
```
2021-09-07 22:50:40 +00:00
Note that you must write to another file, as pdftk cannot overwrite the original file.
Thus, make the file you save the scan as different than what you want the final file to be named.
2021-09-09 00:35:56 +00:00
See [https://sejh.wordpress.com/2014/11/26/changing-pdf-titles-with-pdftk/](https://sejh.wordpress.com/2014/11/26/changing-pdf-titles-with-pdftk/)
2021-09-08 22:12:28 +00:00
2021-09-09 00:30:42 +00:00
# Converting to Double Sided Scans without a Duplexer
This is not an issue if your document scanner has a duplexing unit.
2021-09-08 22:12:28 +00:00
To shuffle pages (interleave double-sided originals):
Scan the front sides: 001a.pdf
This gives you pages 1 3 5 7 9
Scan the reverse sides: 001b.pdf
This gives you pages 10 8 6 4 2
2021-09-09 00:35:56 +00:00
```
$ pdftk A=001a.pdf B=001b.pdf shuffle A1-5 B5-1 output 001.pdf
```
2021-09-08 22:12:28 +00:00
001.pdf should now be in the order:
1 2 3 4 5 6 7 8 9 10
2021-09-09 00:28:35 +00:00
See the sample files included in this repo.