Search This Blog

Friday, 31 October 2008

Automatically split PDF into separate pages

Split PDF into separate pages

In a previous post I showed how to add a header page to a PDF using Pdftk. This example uses the same program to split a PDF into separate pages. See the previous post for Pdftk download info.

The previous post only mentioned WatchDirectory, but you can obviously also use WatchFTP's Batch File Action to do the same thing.

The Batch Script

Use the following batch script to let Pdftk automatically split the newly detected PDF.

If you want to use this script with WatchFTP, to automatically split downloaded PDF's into separate pages, you need to change some variable names in the script.
All variables that start with WD_ must be changed to WF_, for example %WD_REASON% in the script below must be changed to %WF_REASON%.

(The script does not show properly in some blog-readers, please copy it from the original post)

Make sure to properly configure the script in the first few lines (the variables PD and OUTDIR). You probably want to make sure the OUTDIR variable is not set to the directory your WatchDirectory task is monitoring. If it *is* set to that directory, WatchDirectory will call your script again (and again) for the split pages.

No comments: