I would like to print a PDF on windows, but want to print the path of the PDF file in the footer of the printed document (like I am able to do in Word).
We are using either Adobe Reader or Foxit Reader.
Do you know any way how to achieve this ?
OK then. Let me also give it a shot. Since we are here on superuser.com (and not stackoverflow.com), I'll do without a programming language, and use just (batch) scripting instead.
First step: Use Ghostscript to create a PDF footer page showing the 'footer' string with a path
We'll use a relatively simple Ghostscript command for that. The command takes a short PostScript snippet as commandline input (
Now we have a PDF page that contains the footer only, with the rest of the canvas without any content. You can open it in a viewer and see that the string starts at 72 PostScript points (72 pt == 1 inch) to the left of the lower left corner, and 12 points to the top.
Second step: Use the PDF ToolKit to overlay the footer page with your original PDF
We'll use the PDF ToolKit's
(BTW, pdftk is also derived from the iText libarary, the one the other answer refers to.)
Third step: Create a batch script that makes both previous steps happen automatically
This is left for your exercising pleasures... ;-)
You may want to rotate the string by 90 degree, so it reads vertically on the left page border. For this case modify the Ghostscript command like this:
There is no way to auto-update this like the field in Word. But what you can do is process the file after the it is created, and moved to the location other than the source document. PDF was really designed for printing and the changed to allow forms and other stuff was just a hack.
I am guessing that you will want this to be some kind of automated process and generic, so you will need to use a seperate library to do this. One of the most prolific is iText which is a java open source library that allows the editing of PDF files. It is not too hard to use and I will provide an example below of the code you will need to make this exercise work.
You will need the JDK and iText from sourceforge. Here is the java code
This code has some issues, and since I don't know all the specifics then here they are:
Since pdf doesn't have the 'autoupdate' fields you do not want to change the pdf association to point to a script to run this, because then every other time that you open the file it will rewrite the footer.
Here's a windows batch file built from @Kurt's answer:
You may need to change
The units in the
You can print PDF files using the following code:
Or you can also google it and choose a PDF printer to help you with your work. Remember to check its free trial package first if possible. I hope you success. Good luck.