9

I need to intercept data being sent to a ESC/POS printer on Windows and analyze it.

So I wanted to get the data in plain text, so that I can extract and make sense of information being sent to the printer.

Currently, I have tried using RedMon to get the data stream being sent to the printer port. But the data being sent is in the form of raster graphics i.e. dots to be printed, embedded within ESC/POS commands.

So I was wondering if somebody can suggest me on how can I get the print data in text format so as to be able to extract some information from it.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
mabicha
  • 337
  • 2
  • 7
  • 16
  • Can you elaborate? Which application is sending the data? Is it a Java app? Is the source code under your control? Do you really know that text is being sent originally? Can you switch the printer driver to write its output to a file and analyze the content of that file? I am not a printing expert, not a Postscript expert either, but I might have an idea for you how to intercept printing, depending on your answers. – kriegaex Sep 30 '12 at 07:25

3 Answers3

11

The data which is sent to a ESC/POS printer IS raster data embedded with ESC/POS commands. This is what the ESC/POS printer driver generates from its input. And that's what RedMon catched for you.

Seems you want to see the input sent to the printer driver. That means you'll have to find out which applications do use the printer and you have to intercept what arrives at the printer driver.

You do not say if you want to set up your interception in a 'live' environment, or if it is for temporary testing only. If you want to test temporarily, you could alternatively do the following steps:

  1. Pause the print queue (upper screenshot, below).
  2. Optionally: change the driver away from ESC/POS to, say PostScript or Microsoft XPS. Do this on the same "Advanced" tab on the printer properties dialog as mentioned above. (lower screenshot on the right, below).
  3. Print.
  4. Retrieve the spoolfile waiting in the spool directory. On Windows 8 this is by default C:\Windows\System32\spool\PRINTERS. The spoolfile is named NNNNN.spl where NNNNN is the number of the current printjob.
  5. Analyze the PostScript or XPS data.

See these 3 screenshots:

  


However, it would be much easier (instead of using RedMon) if you...

  • ...simply enable the printer driver setting called "Keep printed documents": go to print queue properties => select "Advanced" tab => enable respective checkbox (see left screenshot, above);

  • ...fish spooled printjob from the windows print spool directory;

  • ...analyze your NNNNN.spl file:

    • on Windows 8 this will be an XPS file. Re-name it to NNNNN.xps and you can open it with the builtin XPS viewer.

    • on previous version of Windows, the NNNNN.spl will have the file format of the respective printer driver (PostScript for PostScript drivers, XPS for Microsoft XPS printer, ESC/POS for your printer, ...). Rename it accordingly and open it in XPS or PostScript viewer.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • Hi, So just to confirm: The .spl file will contain the data sent to the printer driver , correct? But I got a little confused when i saw at a tool for printing from the .spl file: http://www.compuphase.com/software_spool.htm If you at this page it is written that "Spool is a small Win32 console utility that sends the contents of a file to the spooler of a Windows printer, bypassing the printer driver." why does it say bypassing the printer driver when this data must actually be sent to the printer driver? – stng Aug 19 '15 at 03:17
  • 1
    @shaarang: I don't know this tool, and don't know how it works. You ***can*** bypass the printer driver if the file format that you want to send to the printer is one which the printer "understands": depending on the model, this could be text, TIFF, PostScript, PDF, PCL or even SVG or XPS. *(Or you want to send arbitrary data to test how the printer behaves then: if it crashes, if it silently ignores "junk", if it prints lots of pages containing "random" characters or empty areas...)* – Kurt Pfeifle Aug 19 '15 at 09:08
  • I think you are right but the file in question is the spool file prepared by windows and anyway what i want to do is to send this .spl to a printer , so i came across : https://support.microsoft.com/en-us/kb/179774 , if you go there you see a command : copy 00002.spl \\\ but i have a local printer installed on my system , then how can i use this command..? Any help would be appreciated. – stng Aug 19 '15 at 09:34
  • @shaarang: your local computer name is your then. – Kurt Pfeifle Aug 19 '15 at 09:37
  • Oh Sorry i am a new to stackoverflow , i will surely upvote now. The Computername is fine but what about the from where i can get that.. – stng Aug 19 '15 at 10:02
  • @shaarang: you could share your printer, then type *"net share"* in a cmd.exe window to see the name. – Kurt Pfeifle Aug 19 '15 at 10:05
  • Actually not very active but tell me .spl file is never in a file format understood by any printer than how can that tool bypass the printer driver ? :P – stng Aug 19 '15 at 10:05
  • Why do i need to share a local printer when its already directly connected to my machine. – stng Aug 19 '15 at 10:11
2

If you just want to capture you could create a TCP/IP printer port that point to the IP of a workstation and run my vclpdcap tool. It monitors 9100 or 515 (RAW or LPR) and captures and writes the data to file.

Take a look here, if you need more instruction let me know.

Updated: http://www.ballisticecho.com/articles/print-capture-lpd-9100

Douglas Anderson
  • 4,652
  • 10
  • 40
  • 49
0

You can put Epson POS printers in debug mode where they will print out a HEX dump of incoming data. See page 88 of this pdf: http://www.pos.epson.com/epsonexpertTSG/Templates/POS_Developers_Details.aspx?NRMODE=Published&NRORIGINALURL=%2fdevelopers%2ftechresdetails%2ehtm%3fproductpk%3d642&NRNODEGUID=%7b934F5A6D-E01A-40B1-B2B0-648C1EC68047%7d&NRCACHEHINT=NoModifyGuest&productpk=642

To make sense of this, you can get the Epson ESC/POS SDK if you sign up and agree to their terms: https://www.epsonexpert.com/ee/prelogin/registration.htm

Teddy
  • 18,357
  • 2
  • 30
  • 42
  • I am looking for a way to intercept printings being sent to a network printer and save documents being printed to a directory before printing is actually done by the printer. Is this possible and if so, how do I achieve this? – Martin Karari Jan 30 '21 at 11:53