How to capture postscript output via TCP/IP? (for testing purposes)

We have a propriety system that talks to various printers across multiple sites via TCP/IP. The system only outputs Postscript, which obviously sends via TCP/IP. I'm really wondering is there any kind of software that I could install my PC which I could setup as like a dummy printer to capture this postscript data.

This would enable me to perform various testing to ensure reports are coming out intact. We have no access to the underlying system or database so this postscript has to be captured as it is output.

I don't need to convert it to PDF or any other format, but that would be nice.


Solution 1:

You don't say what operating system this is, but you could use something like TCPflow, wireshark or tcpdump to capture the packets as it is sent across the network.

If this is Windows, I believe, back in the day, that most printer dialogs let you print to a file. This would presumably be the output of the relevant driver. It's been so long since I used Windows that you can probably safely ignore this paragraph. It's possibly a Windows 3.11 thing.

Solution 2:

This is how I solved this problem:

I setup RawPrinterServer which will listen as a service on port 9100. I then installed RedMon and Ghostscript.

Redmon allows me to create a custom printer port in windows that will forward print jobs to any software you like.

Ghostscript will interpret the incoming postscript and output it as a PDF.

I created a printer in windows with a custom redirected port that directs to the ghostscript executable.

Program path: C:\BIN\gs\gs8.63\bin\gswin32c.exe

Parameters: -sDEVICE=pdfwrite -dPDFX=true -dNOPAUSE -dSAFER -sPAPERSIZE=a4 -sOutputFile="C:\bin\output.pdf" -c .setpdfwrite -f -

Now in the proprietry software that I use, I setup a printer, directing it to the IP of my computer with port 9100.

Now when I print to my new 'printer' the software sends the postscript to my IP, RawPrintServer accepts the TCP data and forwards it to the printer I setup, the custom printer port forwards that data onto Ghostscript, which saves PDF file on my local machine.