Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to add a small header to every page in a PDF on OS X? For example, some option in Preview or something? Maybe even something in AppleScript, etc?

I have a 200+ page PDF file and need to add a small name and account number at the top of every page, and it would be great to be able to do it in an automated way before (or during) printing.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

If you're comfortable with command line, you could use pdftk to do the job.

Here are the steps:

1) Generate a pdf with your header where you want it (bkg.pdf);
2) Use the following command to add the file from 1) as a watermark;

pdftk inputfile.pdf background bkg.pdf output outputfile.pdf

You could generate the header file with e.g. LaTeX, or with Word or other word processing tool, even TextEdit.app.

Edit: Depending on what the contents of your PDF are (e.g. a scanned document), you may prefer a foreground "watermark" to cover the images; in that case, you should replace 'background' by 'stamp' in the above command.

Beware that you might need some iterations to make sure that you have things properly aligned.

Alternative option: use LaTeX to generate the header an include all pages, but it's a bit more involved.

share|improve this answer
    
Just needed to install pdftk and this worked perfectly. I wonder what else I can script up with this toolkit, it'll probably come in handy in my development work from time to time as well. Thanks! –  David Feb 2 '12 at 15:19
    
@David: You're welcome. This toolkit is extremely powerful when using it inside a script. I use it daily for many tasks. Be sure to read the documentation. –  Karolos Feb 2 '12 at 19:52
    
there's a typo in the actual command invocation, it's "pdfdk" rather than "pdftk" –  anddam Nov 26 '13 at 16:52
    
@anddam: Thanks, good catch. Fixed. –  Karolos Nov 27 '13 at 12:16

You can use the Watermark PDF documents action in Automator to add an image on every page of a PDF file. You can specify location, scale, rotation, and opacity.

Manually fixing the workflow for Mac OS X Lion

Set up the entire automator workflow as you would, but skip adding the watermark image (you can't). Save the workflow to a file. Right-click the workflow in Finder and select Show Package Contents and navigate into Contents. Open document.wflow in a text editor, e.g. TextMate.

The actual parameters and their values are stored in the ActionParameters dictionary. The relevant key is filenames. By default, it looks like this:

<key>ActionParameters</key>
<dict>
    <key>angle</key>
    <integer>0</integer>
    <key>fileNames</key>
    <array/>
    <key>onePDF</key>
    <false/>

Just edit the <array/> declaration and add all files as <string>s, like so:

<key>fileNames</key>
<array>
        <string>/Users/danielbeck/Desktop/test.png</string>
</array>

Save the file, and reopen the workflow in Automator. The image will be correctly listed, and you can fix its position and other properties, before you apply it.

Remember that the workflow does not replace the input file as many others do, the output is written to a temporary file. Use the Move Finder Items action afterwards.


Your printer might support a watermark feature via the print dialog. Check for a watermark option in the popup list of the detailed print dialog.

share|improve this answer
1  
The Automator action appears to be broken in Lion. They receive an NSURL from the file dialog, and send the isAbsolutePath message, which is defined for NSString. A really stupid bug. See here. Sorry about that. –  Daniel Beck Feb 2 '12 at 0:38
    
It doesn't look like my printer has that option, but the Automator is definitely worth looking into. (I've never used it before.) Probably won't be able to get to it until tomorrow, so I'll let you know. Thanks! –  David Feb 2 '12 at 0:38
    
Just noticed your recent comment. That might stop it, but it's still worth trying. If I need to, I can probably grab a trial version of a .NET PDF library and develop something custom on my workstation at work. Either way, it'll be tomorrow. –  David Feb 2 '12 at 0:39
2  
@David If you're not afraid of XML, I found out how to circumvent the issue. –  Daniel Beck Feb 2 '12 at 1:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.