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 ?
feedback
|
|
First off: some printer drivers would allow you to define a "watermark" for each page printed. You may be able to abuse that feature in order to do what you want. However, to the best of my knowledge, Acrobat Reader does not include such a feature (though you may be able to (ab)use the builtin JavaScript support inside Acrobat to achieve something like what you want... 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: | |||
|
feedback
|
|
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. Have fun. | |||
feedback
|
|
Here's a windows batch file built from @pipitas answer:
| |||
|
feedback
|