[WinPrnDev] Re: Intercepting data sent to the printer

  • From: "Rocky Harting" <rocky.harting@xxxxxxxxxxxxxxxxxxxx>
  • To: <winprndev@xxxxxxxxxxxxx>
  • Date: Thu, 1 Dec 2011 08:56:52 -0700

That printer uses ESC/POS language.  And, unless the application is
selecting a printer's resident font (if available in the printer driver), or
it is a text only driver (unlikely), you won't be able to actually read the
text and edit it.  Usually, the driver will convert Windows fonts into pixel
information (as Abdul mentions), so all that you will get is a graphics
bitmap representation of the page being sent to the printer.  If you set
your port to print to a file, and open it with a hex editor, you will
probably see a several of 0x1B 0x2A commands followed by some data, which is
the usual ESC/POS graphics command.  If you are lucky though, the
application could be selecting the printer's resident fonts, in which case
you should see the text the application wants printed somewhere in the file.



  -----Original Message-----
  From: winprndev-bounce@xxxxxxxxxxxxx
[mailto:winprndev-bounce@xxxxxxxxxxxxx]On Behalf Of akshay gupta
  Sent: Thursday, December 01, 2011 2:49 AM
  To: winprndev@xxxxxxxxxxxxx
  Subject: [WinPrnDev] Re: Intercepting data sent to the printer


  Hi Abdul,

  I dont want printer to print what I see, first I want to some how get what
I see(not in the raster format ,I want it in a readable format) , then I
want to edit it and may be append some extra information , and finally sent
the edited version of what I see for the printer to print. So in the end
printer wont be exactly printing what I see it would be printing some
altered  version of what I see.

  Regards,
  Akshay


  On Thu, Dec 1, 2011 at 2:04 PM, Abdul Qader mohammed
<abqader.iqbal@xxxxxxxxx> wrote:

    Hi Akshay,


    The info that you obtained in the hex editor is basically pixel
information. It tells the printer how to render each pixel on to the paper.
You have to understand that the driver is not responsible for modifying the
content that is sent to the printer. In fact the driver is responsible for
WYSIWYG (what you see is what you get !!).
    Why would you want to change the content sent by an APP?


    On the other hand :


    Is this "readable text" some command that needs to be sent to the
printer? If so then you will have to start taking a look into the language
monitor.


    Thanks
    Abdul.



    On Thu, Dec 1, 2011 at 1:47 PM, akshay gupta <akshaygupta202@xxxxxxxxx>
wrote:

      Hi Christoph,

      First of all thanks for all your valuable suggestions.I will now share
with you some of my experiences trying to figure out what to do based on
your suggestions. I read about esc/p2 printer language , its basically a set
of printer instructions instructing the printer how to choose fonts,set
printing area, setting printing positions and lot other things.I found a
tool printcapture http://printcapture.com/index.html  which would read epson
printer format and render the file content as an image.I tried opening the
print to file output from EPSON TM-T88IV with this tool , but it could not
open it.This led me to thinking that the format is not exactly esc/p it
could be some variation,because when I open that file in hex editor I can
see some of the  esc character commands listed in the programers manual.Now
my question is how can I extract readable text from the file containing esc
character commands, is there any library that do this kind of work? Or Is
there some way for me to intercept and interpret  the data before it is sent
to  the Epson printer driver? Because doing this I would remove my
dependency on Epson printer divers and also I would save myself from first
interpreting the esc character commands then encoding the edited text back
to the esc character commands.

      PS : I could not try using QPCPrint as setting it  up require redmon
which does not work for windows 7 :-( .


      Regards,
      Akshay









      On Tue, Nov 29, 2011 at 2:40 PM, Christoph Lindemann
<Christoph.Lindemann@xxxxxxxxxxxxxxxxxxx> wrote:

        Hi Akshay,



        The data stream is probably encoded as Esc/POS, a variation of Esc/P
or Esc/P2.

        http://www.undocprint.org/formats/page_description_languages/esc_p2



        You can try the following tool

        QPCPrint http://www.kilgus.net/qpcprint/index.html

        QPCPrint is an emulator that accepts input in ESC/P2 format, be it
text or raster graphics, and outputs the result to any Windows compatible
printer. The emulation has a precision of 1440dpi and matches the output of
a real printer extremely well.



        If the third party application prints directly to the printer,
without using the Windows printer driver, then you can do your own
application, which modifies the Esc/P data. You can get reference manuals at
the Epson Developer website.



        If the third party application uses GDI and the Windows printer
driver (You could check that by testing if the application can print to any
printer installed in windows. For example a HP LaserJet.). Then you could
build your own virtual EMF printer driver, or license one of the many
available EMF printer driver SDK’s:

        http://www.colorpilot.com/emfprinterpilot.html

        http://www.verypdf.com/artprint/mini-emf-printer-driver.htm

        http://www.blackice.com/Printer%20Drivers/EMF%20Printer%20Drivers.ht
m





        Best regards,

        Christoph






------------------------------------------------------------------------

        From: winprndev-bounce@xxxxxxxxxxxxx
[mailto:winprndev-bounce@xxxxxxxxxxxxx] On Behalf Of akshay gupta
        Sent: Tuesday, November 29, 2011 9:30 AM
        To: winprndev@xxxxxxxxxxxxx
        Subject: [WinPrnDev] Re: Intercepting data sent to the printer



        Thanks for quick replies, Ill tell exactly what i want and what i
have tried till now.

        What I want :
        There is a third party application whose task is to generate a
document (which is sort of a bill) and after generating it, it prints that
document. Now I want to some how get the text that printer will  printing
before it actually prints it, and modify it and send the modified text back
to the printer.

        What I have tried:
        I have Experimented with  EPSON TM-T88IV Receipt printers.
        1) I first though that I would print to a file and then read and
edit the contents of that file and send it to the printer for printing. But
the file that it created didnt contained what I expected. It had unreadable
data which I had no idea how to convert it to a readable format.

        2)I tried hooking to the com port and intercept the data that is
flowing through it. But again all I got was a stream of unreadable data.

        Regards,
        Akshay



        On Tue, Nov 29, 2011 at 1:25 PM, Christoph Lindemann
<Christoph.Lindemann@xxxxxxxxxxxxxxxxxxx> wrote:

        Hi Akshay,



        Check out the Windows Driver Development Kit (WDK) documentation
about how the print spooler is working.



        The available options depend on how the application is sending data
to the printer, and what you are trying to accomplish. Is the application
using the GDI API to render the job, or is it sending the data directly to
the printer? Do you want to capture the print like a virtual printer? Or do
you just want to “listen” to the job data, but the data should still go to
the printer? Do you want to modify the data stream? What type is the
printer?



        I think it would be best, if you give us more context information,
describe what you want to accomplish? Why? And what your own ideas are, on
how to do this.



        Best regards

        Christoph




------------------------------------------------------------------------

        From: winprndev-bounce@xxxxxxxxxxxxx
[mailto:winprndev-bounce@xxxxxxxxxxxxx] On Behalf Of akshay gupta
        Sent: Tuesday, November 29, 2011 8:32 AM
        To: winprndev@xxxxxxxxxxxxx


        Subject: [WinPrnDev] Intercepting data sent to the printer



        Hi,



        I am working with an application that prints to a thermal POS
printers in windows environment.
        Can somebody please tell me how can I get the actual text(readable)
after a print command is fired from that application. I have no control over
the code of that application therefore I want to do it at the spooler level
or at the driver level , or some how interpret  the data  flowing through
the COM port.

        Regards,
        akshay








Other related posts: