How to intercept a print job convert it to plain text and print.

Posted on 2013-01-10
2 Endorsements
Last Modified: 2016-02-27
Dear Experts,

I need some advice and tips for a new project i want to start.

I will be working with several bars and restaurants for a loyalty program.

Since all the customers already have a POS Software/Hardware from different vendors, i need to write a program to be able to capture in plain text the final invoice when the POS prints the final receipt.

The process should be something like:

1. The user send the command to the POS software to print the final check
2. The program will intercept the printing job, and create a plain text file and store it into the local PC.
3. The check is printed automatically
4. This should be done in silent mode, the user should not notice anything different.

My questions are:

1. Is this possible to do with POS printers like the ESPONS TM family printers?
2. First i want to build this for windows xp to windows 8
3. Which programming language is more suitable for this task, i can use C# and Delphi

I will give the max point available!!!

Thanks Experts!
Question by:alvarovicente
  • 2
  • 2
  • 2
  • +3
LVL 25

Accepted Solution

Sinisa Vuk earned 167 total points
ID: 38765263
As I see here, you want to make "driver" - application which stands between printer and pos software. You will parse intercepted text or just store to disk?
There are few things which I can recommend here.

1. Make (or buy) com port splitter or virtual com port.
POS sw will connect to splitter  virtual com port, send text, you capture it, make changes and send to real port ....

2. You can use little hw for this (splitter cable, multi com port pci-e card):
Splitter cable can be connected to com1 , one split line goes to com2 and second to real printer. Your application can listen on com2.

- all can be done in c# or Delphi, from xp to win8
- it is not depending on printer - almost all printers can emulate Epson commands
LVL 38

Expert Comment

by:Herman D'Hondt
ID: 38766351
I don't quite understand what you want to achieve. The way I see it you want the user to print a cheque, then extract the text data from that cheque and print it as a cheque. So what's wrong with the first cheque?
LVL 16

Expert Comment

ID: 38766514
Also note that some printers just receive and print a raster image (the printer driver having converted text to raster), and have no concept of text data.

You'd find it quite difficult to extract text from such images.

Author Comment

ID: 38767574

I will try your solution. Yes I need to parse the text at some point for futher processing.


Im writing a loyalty software, since many of my customers have different POS software and I dont have access to their source code, i want to just intercept the receipt when this is sent to the POS printer, in text format, so I can parse it and depending on the loyalty program rules, do further processing with the invoice information, using this method y believe i can reach almost any customer no matter what POS vendor they have installed. Let me know if you get my idea.


So this always happens with POS printers? There is no way to capture before this is rasterize?

Thanks again Experts!!
LVL 16

Expert Comment

ID: 38767606
>> ... So this always happens with POS printers?  ...

I've no idea if this happens with any, all or some POS printers - but it may do!

... and the only way to capture the text would then be before the printer driver rasterised it, so it would be no use capturing the output being sent to the printer port ( unless you are planning on writing an OCR function).

Even if the printers you are targetting accept text characters, these are almost bound to be interspersed with printer control sequences (to move cursor, select font, etc. etc.), so you'd have to have a knowledge of the (perhaps several) printer languages (e.g. Epson ESC/P) in use in order to be able to properly parse the print stream and extract the text (ignoring the printer control sequences).
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

LVL 21

Assisted Solution

developmentguru earned 166 total points
ID: 38767948
I have seen companies that wrote a printer driver... for no printer.  The printer driver would, instead, produce a PDF file.  Any software, using the basics of windows printer APIs, could print to this non-printer.  It seems to me that this would be an ideal place for you to start.  I would start the project by making a working printer driver and make that printer driver capable of being set up to pass all instructions (without change) to another printer driver.  In the meantime your printer driver could do... whatever you need to do with the data.  Some programs may send the printed receipt to the printer as a bitmap.  The only way around this would be to incorporate OCR software.  This has already been mentioned in other questions, just added here for completeness.

Some of these printers may not be set up as a windows printer at all, and may be a custom COM or Parallel port device that is proprietary to the vendor.  If you find this to be the case the the scenario you have been pushing for may not be feasible.

You may find it easier to extract data from the POS software's database, or data export functions.  If you can make this type of setup for each vendor then this would be FAR easier in the long run.
LVL 38

Assisted Solution

by:Herman D'Hondt
Herman D'Hondt earned 167 total points
ID: 38770793
If they all use the same printer, and if that printer uses something like PCL or ESC/P then it is possible. You would still have to set up the PCs to print to a file instead of to the printer port. If the printers only support some form of raster image, then there is no text that you can extract.

Perhaps your best solution is to get the users to use the Generic/Text Only driver, connected to FILE:. That way everything is consistent, and you're guaranteed to be working with text.
LVL 21

Expert Comment

ID: 38770868
Not a bad idea, for the data handling side, but... he will still need to have it come out of their printer of choice... looking the way it always looked...

Author Closing Comment

ID: 38794872
Experts, i will try from all your suggestions, it will take some time to test.

Thanks for your input!!

Expert Comment

ID: 41483764
Hi alvarovicente,

What's your approach to this problem? If you have anything to share. Thanks

Expert Comment

ID: 41483767
hi alvarovicente,

what approach you pick to tackle your problem? if you have share some ideas.  Thanks

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now