Install Pdftk under Windows 7

Although the official installation guide recommends you to install Pdftk by copying the 2 required files** to c:\windows\system32, I personally prefer to keep application specific files outside Windows’ core directory.

Thus, in order to do so simply create a program directory such as C:\Program Files (x86)\pdftk and extract all files from the downloaded zip into it, resulting in the following folder structure:

C:\Program Files (x86)\pdftk
  -> .\bin\
  -> .\docs
  -> .\license_gpl_pdftk

Now you can simple add the bin-folder to the system PATH and you are ready to go. Using this approach it’s easier to update the core Pdftk files without the need to access any Windows’ core folders.

** libiconf2.dll and pdftk.exe

30 thoughts on “Install Pdftk under Windows 7

  1. I’m sorry, I don’t know much about computers, but I’m trying to install and use pdftk. I did want the official installation guide said and copied the files to c:\windows\system32, but when I went to start->run and type in pdftk, a box pops up and tells me “This application has failed to start becuase libiconv2.dll was not found. Re-installing the application may fix this problem.” But I’ve put the libiconv2.dll file in C:\windows\system32.
    So I’ve tried to follow what you suggest and have now put the whole folder in Program Files (x86), but I don’t understand what you mmean by adding the bin-fold to the system PATH?? Could you explain it to me? Thanks a bunch!!!! queenvickitoriaREMOVETHIS@hotmail.com

    • Hello queenvickitoria :razz:

      The error message you’ve posted results from Pdftk not finding libiconf2.dll in your PATH – which is nothing more than a list directories in which Windows (recursively) searches for required files.

      Now to include the bin-directory in your PATH simply right click your “Computer”-icon on the desktop and select “Properties”. Then open the “Advanced System Settings” (Advanced-tab in the system properties window). There select “Environment Variables” which opens another window. In the lower area of this new window you have a list of so-called “System variables”, where you then select “Path” and click “Edit”. In the “Variable value” text field append the following text: “; C:\Program Files (x86)\pdftk\bin\” (note the “;”).

      If you have installed PdfTk in a directoy different from “C:\Program Files (x86)\” simply use this path but be sure to add the “\bin\” directory to it.

      Once you’ve added the bin-path to your PATH environment (and have saved your changes) you should be able to start PdfTk without any problems.

      Hope that helps :smile:

  2. Thanks so much for this post. I had pdftk on XP and had no problems with the installation but I tried to install it on Win7 I would get the error “This application has failed to start becuase libiconv2.dll was not found. Re-installing the application may fix this problem.”

    The post with modifying the system variables saved my life. It now works on 7 as it did on XP. Thanks again for the post. :grin:

  3. I have tried what you explain although I keep having the “This application has failed to start becuase libiconv2.dll was not found.” box appearing.

    I have also tried running pdftk from cmd.exe directly, I get the same.

    I have tried the system32 and your suggestion, but neither work…

    Any ideas? I am running Windows 7
    Thanks for the post!

      • Your invocation works peflcetry well. I cannot fathom right now why I made it so complicated! The only reason I needed a temp folder was to deal with the intermediate PDFs, which I don’t at all need as your example shows. I’ll rework the post shortly, thanks very much for the correction!

  4. Hey matthias kerstner,

    Using the burst command. How should the syntax of the command be when one wants to rename the files. In my case I have a 12 pages file which has 3 types of tables. When burst is applied they are renamed as pg_0001.pdf … pg_0012.pdf.
    But I want them to be like; x1,x2,x3,x4 y1,y2,y3,y4 and z1,z2,z3,z4. Do you got any idea how to hack this?

    • Hello Simon,
      I’m pretty sure that what you are trying to do is not possible out of the box. The pdftk man pages state that you can control the output file names with the output argument using printf formatting style. Now in your case you would need additional conditional logic. I would suggest to use some sort of loop for naming your output files. Hope that helps.

  5. Thanks Matthias,
    But am new to this tool not conversant with it. Any suggestion or example would help.

    • Hi Simon,

      here’s the code you’ve asked for:

      #!/bin/sh

      pdftk_path=pdftk.exe
      infile=pdf.pdf
      filenames=(x1 x2 x3 x4 y1 y2 y3 y4 z1 z2 z3 z4)

      for (( i = 0 ; i < ${#filenames[@]} ; i++ )) do
      `$pdftk_path A=$infile cat A$i output ${filenames[$i]}.pdf`
      done

      Hope that helps. Cheers

  6. Hi Matthias,
    I have installed pdftk with no issues, but the cmd will not recognise it’s prompts. I don’t get any error message. I have installed the files on System32, but it does not seem to work in CMD. Any ideas?

    • Hi Carl,

      I’m not quite sure that I understand you correctly. Do you mean that you start pdftk.exe via the command line and you don’t see any output? Or, do you start pdftk.exe by double clicking it, as doing so will open up a command prompt window but it will close immediately again due to missing parameters.

      • It (pdftk.exe) opens briefly and then closes immediately.

        I’ve added the path to the bin folder and it still doesn’t work. I’m fairly certain I didn’t botch this step as I’ve added to path in environmental variables many times in the past without problems.

        Any ideas?

        • Hi jay,

          sorry for the (very) late reply. If the window opens and closes immediately it means that you either provided the wrong arguments (e.g. none at all) or something is wrong with your configuration.

          I suggest that you try to run pdftk.exe from within an already opened command line window. If there are errors you will see them instead of the window getting closed again. Please try this approach. Hope that helps. Cheers Matthias

  7. Tnx so much, very useful and i’m agree with to keep application specific files outside Windows’ core directory.
    Bye ;)

  8. Hi Suja, a little more information would be great (setup, code, etc.) to help. Have you tried running your script from the command line only, e.g. php -f ./your-script.php and optionally redirect output to a textfile? If not please do so first. Also, have you had a look at this post?

Leave a Comment

Your email address will not be published. Required fields are marked *