Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Pdftk - the pdf toolkit [CMD]


  • Please log in to reply
32 replies to this topic
BoBo
  • Guests
  • Last active:
  • Joined: --

Pdftk - the pdf toolkit

If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. Pdftk is a simple tool for doing everyday things with PDF documents. Keep one in the top drawer of your desktop and use it to:

Merge PDF Documents

Split PDF Pages into a New Document

Decrypt Input as Necessary (Password Required)

Encrypt Output as Desired

Fill PDF Forms with FDF Data and/or Flatten Forms

Apply a Background Watermark

Report on PDF Metrics such as Metadata, Bookmarks, and Page Labels

Update PDF Metadata

Attach Files to PDF Pages or the PDF Document

Unpack PDF Attachments

Burst a PDF Document into Single Pages

Uncompress and Re-Compress Page Streams

Repair Corrupted PDF (Where Possible)

Pdftk allows you to manipulate PDF easily and freely. It does not require Acrobat, and it runs on Windows, Linux, Mac OS X, FreeBSD and Solaris.

[More...]

Windows Program Download
Download and unzip the following file. Move the resulting pdftk.exe to a convenient location, such as C:\windows\system32. Open a command prompt and type pdftk --help. You should get the above, usage instructions.

pdftk-1.12.exe.zip (~1.5MB)

License
My pdftk code is free software made available under the GPL.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


8)

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
Heh... everything but viewing it. Btw, what does this have to do with AHK?

BoBo
  • Guests
  • Last active:
  • Joined: --

Btw, what does this have to do with AHK?

Share your favorite scripts, subroutines, and utility software.
That's how this forum section is labeled :wink:

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
I think if you post a utility here, it should at least have something to do with AHK. Some of the utilities you're posting here are nice, and serve a purpose, but really have no relevance with regards to AHK.

BoBo
  • Guests
  • Last active:
  • Joined: --
@ jonny
Before it gets philosophically. As long as AHK provides no internal PDF features it makes sense (maybe not for you but for others, e.g. like myself).

As AHK provides a command line feature (Run, RunWait) to run whatever you like even third party tools like the recommended one (or a DOSBox, or Word, or Excel, or ...), AHK works as an interface to accomplish whatever task should be done.

If you don't like to get info about usefull tools (beside AHK) ignore it. Thx.
I don't think I won't stop to recommend usefull tools. Maybe someday that'll save someones live(time), even a bit of it :wink:.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i feel its nice to post about new/less-known tools here...

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

I think if you post a utility here, it should at least have something to do with AHK. Some of the utilities you're posting here are nice, and serve a purpose, but really have no relevance with regards to AHK.

The intended scope of the Utilities forum is pretty broad. I didn't want there to be any requirement for a relationship with AHK.

However, it would be preferable that anyone posting a utility have personal experience with it, so that they can vouch for it (unless it's something unusual or obviously useful, such as the PDF toolkit).

pbd
  • Guests
  • Last active:
  • Joined: --
Has somebody already made an ahk script for pdftk? If not, perhaps I could try.

pbd
  • Guests
  • Last active:
  • Joined: --
Here is a GUI for pdftk, made using autohotkey, covering the basic functions. Keep it in the same directory as pdftk.exe and run it.
IfNotExist, pdftk.exe

  {

  MsgBox, pdftk.exe not found in same directory

  ExitApp

  }

Gui, Add, Radio, vOpt, Decrypt PDF file (password should be known)

Gui, Add, Radio, , Encrypt PDF file 128 bit, withhold all permissions

Gui, Add, Radio, , Encrypt PDF file 128 bit, allow printing, `nwithhold other permissions

Gui, Add, Radio, , Encrypt PDF file 128 bit, user needs password to open, `nwithhold all permissions

Gui, Add, Radio, , Encrypt PDF file 128 bit, user needs password to open, `nallow printing, withhold other permissions

Gui, Add, Radio, , Join 2 unencrypted PDF files

Gui, Add, Radio, , Join all unencrypted PDF files in a folder

Gui, Add, Radio, , Remove a page from an unencrypted file

Gui, Add, Radio, , Burst an unencrypted pdf file into single pages

Gui, Add, Radio, , None of the above

Gui, Add, Radio, , About this Gui

Gui, Add, Button, ,OK

Gui, Show, x250 y150, PDF Tool Kit Graphical User Interface

Return



ButtonOK:

Gui, Submit



if Opt=1

  {

  FileSelectFile, arg1,,,"Choose file to decrypt",*.pdf

  InputBox, foopass,,Enter Password, HIDE,

  FileSelectFile, arg2,,,"Choose output file",*.pdf

  RunWait, pdftk.exe %arg1%  input_pw %foopass% output %arg2%.pdf

  }

else if Opt=2

  {

  FileSelectFile, arg1,,,"Choose file to encrypt",*.pdf

  InputBox, foopass,,Enter Password, HIDE,

  FileSelectFile, arg2,,,"Choose output file",*.pdf

  RunWait, pdftk.exe %arg1%  output %arg2%.pdf owner_pw %foopass%

  }

else if Opt=3

  {

  FileSelectFile, arg1,,,"Choose file to encrypt",*.pdf

  InputBox, foopass,,Enter Password, HIDE,

  FileSelectFile, arg2,,,"Choose output file",*.pdf

  RunWait, pdftk.exe %arg1%  output %arg2%.pdf owner_pw %foopass% allow printing

  }

else if Opt=4

  {

  FileSelectFile, arg1,,,"Choose file to encrypt",*.pdf

  InputBox, foopass,,Enter Owner Password, HIDE,

  loop

    {

    InputBox, baz,,Enter User Password, HIDE,

    If baz=%foopass%

      {

      MsgBox, User password should not be owner password

      }

    else

      {

      break

      }

    }

  FileSelectFile, arg2,,,"Choose output file",*.pdf

  RunWait, pdftk.exe %arg1%  output %arg2%.pdf owner_pw %foopass% user_pw %baz%

  }

else if Opt=5

  {

  FileSelectFile, arg1,,,"Choose file to encrypt",*.pdf

  InputBox, foopass,,Enter Owner Password, HIDE,

  loop

    {

    InputBox, baz,,Enter User Password, HIDE,

    If baz=%foopass%

      {

      MsgBox, User password should not be owner password

      }

    else

      {

      break

      }

    }

  FileSelectFile, arg2,,,"Choose output file",*.pdf

  RunWait, pdftk.exe %arg1%  output %arg2%.pdf owner_pw %foopass% user_pw %baz% allow printing

  }

else if Opt=6

  {

  FileSelectFile, in1,,,"Choose first file to join",*.pdf

  FileSelectFile, in2,,,"Choose second file to join",*.pdf

  FileSelectFile, out1,,,"Choose output file",*.pdf

  RunWait, pdftk.exe %in1% %in2% cat output %out1%.pdf

  }

else if Opt=7

  {

  FileSelectFolder, inf,,,"Select folder containing the pdf files"

  FileSelectFile, out1,,,"Choose output file",*.pdf

  RunWait, pdftk.exe %inf%\*.pdf cat output %out1%.pdf

  }

else if Opt=8

  {

  FileSelectFile, arg1,,,"Choose file from which page to be removed",*.pdf

  InputBox, pr,,Give page number to be removed

  FileSelectFile, out1,,,"Choose output file",*.pdf

  pb=%pr%

  pb-=1

  pn=%pr%

  pn+=1

  RunWait, pdftk.exe %arg1% cat 1-%pb% %pn%-end output %out1%.pdf

  }

else if Opt=9

  {

  FileSelectFile, in1,,,"Choose file to burst",*.pdf

  RunWait, pdftk.exe %in1% burst

  }

else if Opt=10

  {

  MsgBox, "Sorry, your requirement is not yet included"

  }

else

  {

  MsgBox, This script developed by Dhanish`nwww.dhanish.150m.com/software.html`nFor PDF tool kit, visit http://www.accesspdf.com/pdftk/

  }

GuiClose:

GuiEscape:

ExitApp
A compiled version can be downloaded from www.dhanish.150m.com/software.html

BoBo
  • Guests
  • Last active:
  • Joined: --

A compiled version can be downloaded from www.dhanish.150m.com/software.html

and directly from here (without being bothered by an "wanna install an AddWare?"-Popup) request) [PDFTKgui]

@ pbd
Thx for sharing it. Much appreciated.

BoBo
  • Guests
  • Last active:
  • Joined: --
:shock: My above advise/link won't work as pbd's web account isn't enabled for "Hotlinking". Sorry folks. :oops:

A Hotlinking Error Has Occured!

We have detected a hotlinking error. Hotlinking is when you link to images or NON html files on 150m.com from another host. Hotlinking is not allowed for our FREE Accounts. Hotlinking is allowed for our paid accounts. Your account can be upgraded in the user section when you have logged in.



pbd
  • Guests
  • Last active:
  • Joined: --
Oops, the above script will not work if the path / filename contains blank spaces. This can be overcome by adding inverted commas for the variable names.

But this will not work for option 7 while selecting a directory with *.pdf. Can AutoHotkey capture shortnames of directory paths?

The compiled version has been corrected.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Can AutoHotkey capture shortnames of directory paths?

A way was recently added:
Loop %MyFileName%

    ShortPath = %A_LoopFileShortPath%


olaf
  • Guests
  • Last active:
  • Joined: --
I have not tried pdftk, but use xpdf a lot. it probably doesn't do all
what pdftk says it does, but it does what i need, like pdftotext.

http://www.foolabs.com/xpdf

new
  • Guests
  • Last active:
  • Joined: --
Hi all,

I want to repair pdfs in my file structure, we have very big files structure.
I'm trying to use pdftk.exe tool, which is very cool, but I want to use it for multiple pfds, and typing:

pdftlk.exe file1.pdf output file1good.pdf | pdftlk.exe file2.pdf output file2good.pdf | pdftlk.exe file3.pdf output file3good.pdf ...

is not something that I want to do every time. Can someone help me with developing some script for using pdftk.exe to repair all *.pdf in current "dir" ??

pdftk.exe *.pdf output *.pdf
doesn't work

thanks.