watchDirectory Help > Plugins > Automatically run .bat files > Automatically Convert PostScript to PDF
Automatically Convert PostScript to PDF
This script is started by watchDirectory to automatically convert PostScript® files, typically with a PS or EPS extension, to PDF (Portable Document Format). When a new PostScript file is detected in the monitored directory, watchDirectory starts this script to convert it to PDF. This makes watchDirectory a low cost alternative to Adobe® Acrobat® Distiller® (discontinued by Adobe, replaced by Adobe LiveCycle® PDF Generator).
What you need
The script uses AFPL Ghostscript to perform the actual conversion. You can download AFPL Ghostscript here.
If the link above does not work anymore, please download the latest version via http://www.cs.wisc.edu/~ghost.
Settings for this script
The upper half of the settings dialog contains general settings for all scripts that can be started by the Automatically run .bat files plugin. Please see that page for instructions.
GSDIR - Where did you install Ghostscript
Here you enter the location where Ghostscript is installed. Older versions of Ghostscript by default install in C:\GS\GS8.XX. The current
versions install in C:\Program Files\GS\GS8.5X. Press the "Browse" button to locate the directory.
OVERWRITE - If the PDF file already exists
If the target PDF file already exists, you can choose to overwrite or rename the existing PDF. If you choose to rename it,
the script will add underscores to its name to make it unique.
TARGETDIR - Place the PDF files in this directory
Where should the new PDF files be created?
DELETEPS - Delete PostScript file after conversion to PDF
When the PDF is created, the script can automatically remove the original postscript file.
TIP - Add extra functionality
Ghostscript can do a lot more than just convert to PDF. Your install of Ghostscript comes with a lot of documentation about extra parameters you can use to add functionality. Please look at the document C:\Program Files\gs\gs8.53\doc\Ps2pdf.htm (change according to your version of Ghostscript).
Example: create password protected PDF files
To make the PDF password protected, we need to add 2 commandline options when the Ghostscript PS2PDF.BAT file is started. These options are
-sOwnerPassword=pwd1 -sUserPassword=pwd2
- Start the watchDirectory Control Center.
- Press Ctrl+9 (or use the "Tools -> Explore Task Directory" menu option) to open the directory where watchDirectory stores all your task information.
- Open the sub directory with the same name you just gave to the new task.
- Inside this directory you will find the script that is started by watchDirectory. It is the file called WD.BAT.
- Open WD.BAT with a plain text-editor (notepad), do not use a word processor to edit the file!!
- Find the line that starts PS2PDF.BAT (line number 67, near the bottom of WD.BAT), by default it looks like:
CALL PS2PDF.BAT "%WD_FILE%" "%TARGETDIR%\%WD_FILE_B%.PDF"
- Add the 2 options to this line so it looks like:
CALL PS2PDF.BAT "-sOwnerPassword=secret" "-sUserPassword=secret" "%WD_FILE%" "%TARGETDIR%\%WD_FILE_B%.PDF"
- Be sure to include the "quotes" as shown. When you now start the task, new PDF files will be password protected with the password secret.