Search This Blog


Friday, 5 September 2008

Automatically add a header page to new PDF documents

The example batch script below will combine 2 PDFs using the pdftk program (Auf Deutsch).
One of the PDF files is a "static" page that will be used as the "header" for the output PDF. The other PDF file is the file detected by WatchDirectory.

Download pdftk

You can download the Windows version of pdftk here:

WatchDirectory task

Create a new task and select the run a batch file plugin. Select the sample batch script below (make sure you changed its settings the way you need). Make sure you only select the "FILENEW" option on the Events page.

The example batch script

Below is the example script. Please make sure to change the 3 settings starting on line 5 to the correct location of pdftk, the header.pdf you want to use and the output directory.
(The script does not show properly in some blog-readers, please copy it from the original post)

If you want the script to automatically delete the original PDF, remove the REM on the last line.

A small variation

If you want to add the static page as the last page of the new PDF, change line 15 from (original):

"%PD%" "%HDP%" "%WD_FILE%" cat output "%OUTDIR%\%WD_FILE_N%"

to (new):

"%PD%" "%WD_FILE%" "%HDP%" cat output "%OUTDIR%\%WD_FILE_N%"

No comments: