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

How helpful was this content for you?

You may also like...

33 Responses

  1. queenvickitoria says:

    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 πŸ˜›

      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. weston.bassler says:

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

     
  3. Nicolas says:

    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!

     
  4. mas says:

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

     
  5. Simon says:

    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.

       
  6. Simon says:

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

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

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

    • carl says:

      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.

         
        • jay says:

          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

             
    • bazzilic says:

      Hi!

      I created an .msi installer for pdftk 1.44. You can find link in my blog post here: http://bazzilic.livejournal.com/101275.html. I will update it when new version will be released.

      Cheers!

       
    • Marcofe says:

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

       
    • Suja says:

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

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

       
    • Jessica says:

      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?

       
      • Jessica says:

        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.

         
    • 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…)
      Cheers

       

Leave a Reply

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