Answers.Body: <p><a href="https://en.wikipedia.org/wiki/Pdftk" rel="noreferrer">pdftk</a>, the PDF toolkit, is a program that has been around since 2004, and is available for multiple platforms: Windows, Linux, OSX. Although you could probably compile (it is open source) and run it on some (Android based) ebook readers, it is more intended to be run on your main computer, to change files before loading them onto your ebook reader.</p>
  <p><code>pdftk</code> can do a lot of things out-of-the-box: collate scanned PDF pages (including handling reverse ordered back sides); decrypt and encrypt PDFs; joining and splitting of PDFs; removing of pages; rotating (90° increments) of pages; reporting on PDF metatdata and bookmarks.</p>
  <p><code>pdftk</code> is built on top of the <a href="https://en.wikipedia.org/wiki/IText" rel="noreferrer">iText</a> java library. It's development history is documented by its <a href="http://www.pdflabs.com/docs/pdftk-version-history/" rel="noreferrer">revision history</a>.</p>
  <h1>Installation</h1>
  <h2>Windows</h2>
  <p>For <strong>Windows</strong> (XP, Vista, 7, 8), use the installer that you can get directly from the <a href="http://www.pdflabs.com/tools/pdftk-server/" rel="noreferrer">pdftk pages at PDF Labs</a>. Run the executable installer, you should select the option [Don't create a Start Menu Folder]², but make sure you leave [Add application directory to your environment path] selected.</p>
  <p>Now you can open the Command Prompt (in the &quot;Accessories&quot; program group) and type³:</p>
  <pre><code>pdftk --version
  </code></pre>
  <p>to make sure the program is correctly installed. You can now use the examples provided in the answers that were mentioned in the question.</p>
  <h2>OSX</h2>
  <p>You can download the Mac OS X installer (for Snow Leopard, Lion and Mountain Lion) from <a href="http://www.pdflabs.com/tools/pdftk-server/" rel="noreferrer">pdftk pages at PDF Labs</a>, or use <a href="https://github.com/phinze/homebrew-cask" rel="noreferrer">homebrew-cask</a> as explained in <a href="https://github.com/phinze/homebrew-cask" rel="noreferrer">this StackOverflow answer</a>:</p>
  <pre><code>brew cask install pdftk
  </code></pre>
  <p>After that, open a <a href="https://en.wikipedia.org/wiki/Terminal_%28OS_X%29" rel="noreferrer">Terminal</a> and type</p>
  <pre><code>pdftk --version
  </code></pre>
  <p>to make sure the program is correctly installed. You can now use the examples provided in the answers that were mentioned in the question.</p>
  <h2>Linux</h2>
  <p>Most Linux distributions include <code>pdftk</code>, try</p>
  <pre><code>sudo apt-get install pdftk
  </code></pre>
  <p>or</p>
  <pre><code>sudo yum install pdftk
  </code></pre>
  <p>or pick another installer appropriate to the distribution.</p>
  <p>After installation, open a terminal (if not already open for the installation process) or switch to a console (<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>F1</kbd>) and type:</p>
  <pre><code>pdftk --version
  </code></pre>
  <p>to make sure the program is correctly installed. You can now use the examples provided in the answers that were mentioned in the question.</p>
  <h1>Usage</h1>
  <p><code>pdftk</code> is not hindered by a graphical user interface, therefore it is easy to automate repetitive tasks⁴. The examples in the answers, e.g.:</p>
  <pre><code> pdftk *.pdf cat output ../combined.pdf
  </code></pre>
  <p>(to combine multiple PDF files in one file), can be copied and pasted from your web browser into your command prompt/terminal.</p>
  <p>To find out about other easy ways to manipulate your PDF files, try:</p>
  <pre><code>pdftk --help
  </code></pre>
  <p>or have a look at the <a href="http://www.pdflabs.com/docs/pdftk-man-page/" rel="noreferrer">manual pages</a>.</p>
  <p>When in a hurry, and only having to do things once, it is sometimes easier to burst a while PDF into individual pages with:</p>
  <pre><code>pdftk in.pdf burst
  </code></pre>
  <p>then remove the pages you don't need anymore, or rearrange them by renaming them, and then combine them using:</p>
  <pre><code>pdftk pg_*.pdf cat output out.pdf
  </code></pre>
  <p>(this combines the pages in alphabetical order so if you want the original page 2 to go after page 3, just rename <code>pg_0002.pdf</code> to <code>pg_0003a.pdf</code>).</p>
  <p>¹ <sub>If you don't mind doing repetitive tasks moving a mouse around, there is also a GUI based version of the program: PDFtk Free</sub><br>
  ² <sub>That only creates a superfluous entry in the Program menu with an Uninstall option, you can do that from the &quot;Add/Remove Programs&quot; in the Control Panel</sub><br>
  ³ <sub>If you are not familiar with using the commandline: you have to type the characters shown and at the end of the line press <kbd>Enter</kbd></sub><br>
  ⁴ <sub>For instance by calling it from a batch file, a shell script or (my favourite) a Python program</sub><br></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-08T07:42:48.700Z
Answers.Text: Anthon, would you mind talking a bit about what pdftk does? You cover its history and how to install it, but not why I would want to install it or what I would do with it. Thanks!
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-08T07:45:51.060Z
Answers.Text: @Tom That is a good idea, but I will try to add the highlights of the usage only, don't want to copy and paste the whole manual ;-). The history is less relevant here (IMHO), but I will try to find a link for those interested, OK?
Answers.UserDisplayName: Anthon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-08T07:47:34.887Z
Answers.Text: Sounds reasonable--definitely no need for the whole manual. Just a simple overview of what it does would be great!
Answers.UserDisplayName: Tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-03-08T07:35:07.423Z
Answers.LastActivityDate: 2014-03-08T08:02:37.673Z
Answers.LastEditDate: 2020-06-18T08:36:04.683Z
Answers.UserDisplayName: Anthon
Body: <p>There are answers by asalamon74 (<a href="https://ebooks.stackexchange.com/questions/534/how-can-i-personalize-each-copy-of-a-pdf-to-add-the-readers-name-or-email-addre/546#546">here</a>), and by anthon (<a href="https://ebooks.stackexchange.com/questions/875/high-resolution-small-size-pdf/878#878">here</a>, <a href="https://ebooks.stackexchange.com/questions/1067/how-can-i-merge-multiple-ebooks-in-a-single-file/1077#1077">here</a> and <a href="https://ebooks.stackexchange.com/questions/1069/how-can-i-extract-some-chapters-or-sections-from-an-ebook-into-a-new-one/1078#1078">here</a>), that use <code>pdftk</code>. </p>
  
  <p>I don't think I have <code>pdftk</code> installed on my ebook reader¹. How and where do I install it, and once installed how can I use it?</p>
  
  <hr>
  
  <p>¹ <sub>This Q&amp;A was inspired by <a href="https://ebooks.stackexchange.com/questions/1067/how-can-i-merge-multiple-ebooks-in-a-single-file/1077#comment1228_1077">this comment</a>, which essentially could have been the above question. I did not find it appropriate to clobber each and every of my answers with installation and usage instructions for people that cannot seem to find those instructions using a search engine. Imagine the bloat that we would have if every answer with a reference to Calibre, Word or Open/Libre-office would have multiple paragraph about how to install such an application on each possible platform.</sub></p>
  
Tags: <pdf><conversion>
Title: How can I use pdftk to make changes to my PDF ebooks?
UserDisplayName: Anthon
ThreadText: # How can I use pdftk to make changes to my PDF ebooks?
  
  (Asked by: username_0 on 2014-03-08)
  
  There are answers by asalamon74 ([here](https://ebooks.stackexchange.com/questions/534/how-can-i-personalize-each-copy-of-a-pdf-to-add-the-readers-name-or-email-addre/546#546)), and by username_0 ([here](https://ebooks.stackexchange.com/questions/875/high-resolution-small-size-pdf/878#878), [here](https://ebooks.stackexchange.com/questions/1067/how-can-i-merge-multiple-ebooks-in-a-single-file/1077#1077) and [here](https://ebooks.stackexchange.com/questions/1069/how-can-i-extract-some-chapters-or-sections-from-an-ebook-into-a-new-one/1078#1078)), that use `pdftk`.
  
  I don't think I have `pdftk` installed on my ebook reader¹. How and where do I install it, and once installed how can I use it?
  
  ---
  
  ¹ This Q&A was inspired by [this comment](https://ebooks.stackexchange.com/questions/1067/how-can-i-merge-multiple-ebooks-in-a-single-file/1077#comment1228_1077), which essentially could have been the above question. I did not find it appropriate to clobber each and every of my answers with installation and usage instructions for people that cannot seem to find those instructions using a search engine. Imagine the bloat that we would have if every answer with a reference to Calibre, Word or Open/Libre-office would have multiple paragraph about how to install such an application on each possible platform.
  
  **Tags:** pdf, conversion
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2014-03-08. Score: 6
  
  [pdftk](https://en.wikipedia.org/wiki/Pdftk), the PDF toolkit, is a program that has been around since 2004, and is available for multiple platforms: Windows, Linux, OSX. Although you could probably compile (it is open source) and run it on some (Android based) ebook readers, it is more intended to be run on your main computer, to change files before loading them onto your ebook reader.
  
  `pdftk` can do a lot of things out-of-the-box: collate scanned PDF pages (including handling reverse ordered back sides); decrypt and encrypt PDFs; joining and splitting of PDFs; removing of pages; rotating (90° increments) of pages; reporting on PDF metatdata and bookmarks.
  
  `pdftk` is built on top of the [iText](https://en.wikipedia.org/wiki/IText) java library. It's development history is documented by its [revision history](http://www.pdflabs.com/docs/pdftk-version-history/).
  
  # Installation
  
  ## Windows
  
  For **Windows** (XP, Vista, 7, 8), use the installer that you can get directly from the [pdftk pages at PDF Labs](http://www.pdflabs.com/tools/pdftk-server/). Run the executable installer, you should select the option [Don't create a Start Menu Folder]², but make sure you leave [Add application directory to your environment path] selected.
  
  Now you can open the Command Prompt (in the "Accessories" program group) and type³:
  
  ```
  pdftk --version
  
  ```
  
  to make sure the program is correctly installed. You can now use the examples provided in the answers that were mentioned in the question.
  
  ## OSX
  
  You can download the Mac OS X installer (for Snow Leopard, Lion and Mountain Lion) from [pdftk pages at PDF Labs](http://www.pdflabs.com/tools/pdftk-server/), or use [homebrew-cask](https://github.com/phinze/homebrew-cask) as explained in [this StackOverflow answer](https://github.com/phinze/homebrew-cask):
  
  ```
  brew cask install pdftk
  
  ```
  
  After that, open a [Terminal](https://en.wikipedia.org/wiki/Terminal_%28OS_X%29) and type
  
  ```
  pdftk --version
  
  ```
  
  to make sure the program is correctly installed. You can now use the examples provided in the answers that were mentioned in the question.
  
  ## Linux
  
  Most Linux distributions include `pdftk`, try
  
  ```
  sudo apt-get install pdftk
  
  ```
  
  or
  
  ```
  sudo yum install pdftk
  
  ```
  
  or pick another installer appropriate to the distribution.
  
  After installation, open a terminal (if not already open for the installation process) or switch to a console (`Ctrl`+`Alt`+`F1`) and type:
  
  ```
  pdftk --version
  
  ```
  
  to make sure the program is correctly installed. You can now use the examples provided in the answers that were mentioned in the question.
  
  # Usage
  
  `pdftk` is not hindered by a graphical user interface, therefore it is easy to automate repetitive tasks⁴. The examples in the answers, e.g.:
  
  ```
   pdftk *.pdf cat output ../combined.pdf
  
  ```
  
  (to combine multiple PDF files in one file), can be copied and pasted from your web browser into your command prompt/terminal.
  
  To find out about other easy ways to manipulate your PDF files, try:
  
  ```
  pdftk --help
  
  ```
  
  or have a look at the [manual pages](http://www.pdflabs.com/docs/pdftk-man-page/).
  
  When in a hurry, and only having to do things once, it is sometimes easier to burst a while PDF into individual pages with:
  
  ```
  pdftk in.pdf burst
  
  ```
  
  then remove the pages you don't need anymore, or rearrange them by renaming them, and then combine them using:
  
  ```
  pdftk pg_*.pdf cat output out.pdf
  
  ```
  
  (this combines the pages in alphabetical order so if you want the original page 2 to go after page 3, just rename `pg_0002.pdf` to `pg_0003a.pdf`).
  
  ¹ If you don't mind doing repetitive tasks moving a mouse around, there is also a GUI based version of the program: PDFtk Free  
  ² That only creates a superfluous entry in the Program menu with an Uninstall option, you can do that from the "Add/Remove Programs" in the Control Panel  
  ³ If you are not familiar with using the commandline: you have to type the characters shown and at the end of the line press `Enter`  
  ⁴ For instance by calling it from a batch file, a shell script or (my favourite) a Python program
  
  > **Comments:**
  > **username_1**: username_0, would you mind talking a bit about what pdftk does? You cover its history and how to install it, but not why I would want to install it or what I would do with it. Thanks!  
  > **username_0**: @username_1 That is a good idea, but I will try to add the highlights of the usage only, don't want to copy and paste the whole manual ;-). The history is less relevant here (IMHO), but I will try to find a link for those interested, OK?  
  > **username_1**: Sounds reasonable--definitely no need for the whole manual. Just a simple overview of what it does would be great!  
  
  ---
  
  