Posted by beakersoft | Posted in Applications | Posted on 07-01-2008
Working at a newspaper we use postscript files a lot, so I have used Ghostscript for various purposes in the past, along with the printer port redirection application Redmon. Redmon lets you create a new printer port, then re-directs the output of the printer to where ever you want. Using this you can call Ghostscript and create a PDF printer. There’s a good how to of this at http://www.stat.tamu.edu/~henrik/GSWriter/GSWriter.html
If you follow this walk through, it will work fine for most situations. The only problem is it prompts for a file name after every file is printed, so if you have a process that generates a lot of print files one after each other, you want it to name the files on its own. This was the situation I was in.
We have a process that runs on an account system that creates 100’s of separate print files. Instead of printing them all out, we wanted to save a copy of them to pdf, print the pdf’s using Batch Print Pro then save the pdf’s in case they needed to be re-used. By doing this we would save on network bandwidth by sending the print file to the remote site (a 80k pdf instead of a 1.5mb+ print spool file), and if the file needs to be sent out again the process in the accounts system wouldn’t have to be run again, the file could just be re-printed.
In order to do this, we create a printer with a redmon port, then re-direct the output of the printer to a vbscript. Within the script the following happens:
- The path to the temporary postscript file that is created as the job is printed is pased to the script as an argument
- A variable to hold the output name and path is created. The output file name is based on the document name (groveled out of the temp postscript document) and a random number to stop duplicate files being produced.
- The ps2pdf batch file is then called using a shell command. This is a batch file shipped with Ghostscipt that (surprisingly) converts postscript files to pdf’s. You pass the batch file an input file (in this case the temp postscript file) and an output file.
The setup of the Redmon port looks like this:
Theres a couple of things to check if your having problems:
- If your output is coming out in mono, make sure you are using a colour printer driver!
- If you are printing a crystal report (like I was) and it’s coming out mono even if you are using a colour printer driver, open the report in crystal and go to File -> Print -> Printer. If this is set to a mono printer it will still print in mono. Change it to a colour printer and it should be fine
- As always, make sure the directory’s you are writing to are open to the users who will need them.
- Make sure the Ghostscript bin and lib folders are in your %path% variable, or when you call the batch file from the script it wont be able to find everything it needs.
Download the script: Batch_PDFPrint.vbs