Printing current date and time on each page

cupsprinting

I'm often printing several versions of a document (e.g. a paper in progress). To keep track of the printouts I would like to print the date and time of printing onto each page, regardless of which application I'm using (although it would be okay if it works for PDF files only, if it happens automatically). I have seen Windows printer drivers including this feature, but haven't found any settings here (e.g., Canon iR3225) nor any hidden-CUPS-feature-I-could-activate-in-the-config-file.

Any ideas? Some sort of preprocessing I could inject into cups?

(I'm using Mac OS X 10.6.7)

Best Answer

I finally found a usable solution using convert from ImageMagick, the PDF services mentioned by nathang and Automator.

  1. Start Automator, create a new "Print Plugin"
  2. Drag the "run shell script" action to the right and enter the following script:

    export PATH=/opt/local/bin:/usr/local/bin:$PATH
    convert -size 400x50 xc:white -font Arial -pointsize 24 -gravity center -draw "fill grey50 text 0,0 '`/bin/date`'" /tmp/stamp.png
    cat
    
  3. Add the "Watermark PDF Documents" action and add the file "/tmp/stamp.png" using the 'add...' button. (You probably have to create this file first, e.g. using touch /tmp/stamp.png in a Terminal). Then adjust the offset, scale and opacity as you like. I'm using x=480 y=820 scale=0.25 opacity=0.7.
  4. Add the "Open Images in Preview" action.
  5. Save the Automator script.

Now you should find a new action in the "PDF" drop-down menu of your printing dialog, which stamps the current date and time on each page and shows the result in Preview, from where you can print the document.