Search code examples
asp.netprintingdevice-driver

Receive raw print data in asp.net?


I would like to be able to have a Printer installed on a windows client. When someone prints to said printer it captures the print stream and dumps it into a file. I will eventually need to parse this data and put the results into a SQL database. Is this possible? where do i start.

If your wondering why i need this its because there is an application i need to pull data from, i cant install anything on the computer its running on so i figured if i set up a network printer and have it send information that way it could work.

I'm pretty much lost in the sauce on this one so if any can even point me in the right direction i would appreciate it.


Solution

  • RedMon is a little print driver wrapper that redirects print data to a program of your choice.

    You would need to install two things on the Windows client:

    1. RedMon
    2. your custom program (written in C# or whatever)

    When the user "prints" to the virtual printer, RedMon sends the data to your custom program, which parses it, saves it to a database, etc.

    cant install anything on the computer ... set up a network printer

    For your situation, note this key portion of the RedMon documentation:

    Using RedMon you create redirected printer ports. If you connect a Windows printer driver to the redirected printer port, all data sent to the redirected port will be forwarded by RedMon to the standard input of a program. This program is then responsible for processing the data and producing new output.

    A PostScript Windows printer redirected to a RedMon port can be shared on a network. When this printer is configured to use Ghostscript and a non-PostScript printer, it appears as a PostScript printer to other network clients.

    In other words, you can set up RedMon on some other computer, then share it on the network, and then the locked-down computer can print to that network "printer".

    On Windows 7, RedMon has quirks but there is a workaround.

    See also: How to write a driver for virtual printer