Posted on 36 Comments

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

36 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!!!!

    1. Hello queenvickitoria ๐Ÿ˜›

      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 ๐Ÿ™‚

      1. Hi matthias.kerstner
        thank you for the help, i think it work ๐Ÿ˜‰
        i just want to ask if you have an exemple to how to use php with pdftk ๐Ÿ™‚

        thank you

        1. Hello Issam,

          to execute PdfTk from within PHP you need to call exec1, or passthru2 depending on whether you need the data returned by PdfTk or not, e.g.

          PHP’s exec/passthru will delegate the call to PdfTk. In case you are planning to use user defined variables in order to call PdfTk please make sure to use escapeshellarg3 or escapeshellcmd4 to escape them in order to prohibit malicious input.

          Hope that helps.


        2. Thank you very much!
          I found I had to delete the space after the semicolon… “; C:\Program Files (x86)\pdftk\bin\”

          After that it works great!

          1. Hi Stuart,
            thanks for the feedback. Glad it worked out for you. Cheers

  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. ๐Ÿ˜€

    1. Glad I could help ๐Ÿ˜›

  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!

    1. Hello Nicolas,

      please create a folder c:\pdftk\ and copy libiconv2.dll and pdftk.exe into it. Then add c:\pdftk\ to your PATH as described above. Just to be sure restart Windows after updating the PATH. This should do the trick. Hope that helps.

      1. It does the trick yes, thank you!
        (On seven 64)

        1. You’re welcome ๐Ÿ˜›

  4. ๐Ÿ˜€ Thank you so much Matthias. Your posting is so helpful.

      1. 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!

  5. 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?

    1. 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.

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

    1. Hello Simon, I’ll post an example later on that should do the trick. Cheers

    2. Hi Simon,

      here’s the code you’ve asked for:


      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` doneHope that helps. Cheers

  7. 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?

    1. 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.

      1. 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?

        1. 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

  8. Hi!

    I created an .msi installer for pdftk 1.44. You can find link in my blog post here: I will update it when new version will be released.


    1. Hi bazzilic,
      thanks for your link and thanks for Google Translate as I am not fluent in Russian ๐Ÿ˜‰

  9. Tnx so much, very useful and i’m agree with to keep application specific files outside Windowsโ€™ core directory.
    Bye ๐Ÿ˜‰

    1. Hi Marcofe,
      I’m glad this was useful for you. Thanks for the feedback ๐Ÿ˜›

  10. I am not able to run pdftk from php. I’m not getting any error. Can you please help me out

  11. 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?

  12. I just installed this and tried to run it from the command prompt because it just opened and closed when I double clicked on the exe file. I went to the bin folder and typed in what I understand to be the command to repair the file (pdftk C:\etcetera). However, I get this and I am not sure what I am not doing right.

    Done. Input errors, so no output created.

    How do I know what my input errors are so I know to correct them?

    1. Nevermind. I figured out how to export the Help file to a txt file. After reading it, I do not think pdftk will do what I need. I have a PDF file that needs to be repaired and it does not appear that pdftk will do that. Thanks anyway.

  13. Hi Jessica,
    pdftk is capable of repairing PDFs. Simply use the following command:

    pdftk <broken PDF filename> output <fixed PDF filename>

    pdftk will inspect the (potentially) broken PDF file specified and try to repair it while writing the corrected bytes to a new file.

    Hope that helps (even if the answer comes late…)

  14. Thank you! Exactly what I was looking for. Works on Windows 10 too.

  15. Just to mention that since this (excellent) article PDftk Server download is no longer a zip (still at linked address), rather an OS-specific install. So the Windows installer now creates a PDftk Server folder under C:\ProgramFiles(x86) and edits the Windows environment file to add that directory to paths. So running the installer should take care of everything for you.

    1. Hi Stephen, thanks a bunch for the hint! I will update the post accordingly. Cheers, Matthias

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.