0

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.

Michael Galos
  • 153
  • 1
  • 5

7 Answers7

3

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.

David Pashley
  • 23,151
  • 2
  • 41
  • 71
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.

Michael Galos
  • 153
  • 1
  • 5
1

I would vote for Wireshark, as it is able to easily follow the TCP strem for the LPD protocol and save it to a file.

I just tested that, and all you have to to is stripping a few lines from the beginning of the output file and you have valid PS.

Sven
  • 97,248
  • 13
  • 177
  • 225
1

I would have netcat listen on your local LPD port and write what it receives to a file. For example:

nc -l -p 515 > output.ps
Joe
  • 1,535
  • 1
  • 10
  • 15
  • 1
    Note that you don't get a valid postscript from that, as there a few lines of lpd headers before the postscript starts. But it's easy to remove them. – Sven Jun 15 '09 at 15:52
  • That sounds great. Note that you can also get ncat, which is purportedly netcat on steroids and part of the nmap project. http://nmap-ncat.sourceforge.net/ – Clinton Blackmore Nov 03 '09 at 23:13
0

Is the proprietory system printing using LPR? If so you could, in principle at least, run an LPR server that wrote the postscript it receives to a file instead of to a printer. I don't know of one offhand, though a quick Google revealed quite a lot of Windows LPR related stuff.

If you're handy with a C++ compiler I have the code for an LPR server lying around somewhere. I wrote this back in the NT3.50 days before Windows supported LPR natively. It wouldn't be hard to modify the code to send the output to a file instead of a printer port. This has to be a last resort though, there must be something out there that does the job.

One thought. Suppose you install the Windows unix printing support on your workstation or some convenient server then put the printer offline and print to it. The postscript would presumably appear in the C:\Windows\system32\spool\PRINTERS somewhere.

JR

John Rennie
  • 7,756
  • 1
  • 22
  • 34
0

On Linux you could use tcpdump or wireshark, on Windows I only know of wireshark, personally I like wireshark better because it has a nice GUI, however you can record tcpdump to a file and feed that to wireshark for later analysis

Martin M.
  • 6,428
  • 2
  • 24
  • 42
0
  1. Setup a postscript printer which is on 127.0.0.1.

    Adding a post script printer on OSX

  2. Start a netcat server process to fake the printer. HP Jetdirect uses port 9100 nc -l 127.0.0.1 9100 > printout.ps

  3. Print your document and enjoy the postscript grooviness :)

PS: I did this to get around content viewing restrictions on PDFs.

Lmwangi
  • 342
  • 1
  • 6