Search code examples
c#windows-servicesprintingwmiwdk

Print Job Accepting and routing Software


I want to create a software which can accept Print Jobs from other computers, and then route those print jobs to PCs on LAN with printers attached.

How it's going to happen -> 1- When that software called "Virtual Printer" is installed on a computer "X", Windows should think that it is a print driver/attached printer to that computer. 2- Then administrator of that PC goes to "Devices and Printers" in windows and select the "Virtual Printer", right click and view properties and select the check box "Share this printer" 3- Now other PCs on the LAN can see that there is a shared printer call "Virtual printer" in the LAN connected to the computer "X" 4- So they can send print jobs to this "Virtual Printer", by selecting "Virtual Printer" when they need to print something.

How can I write this program (possibly c#) to Appear itself as a printer to the Windows, and then Accept incoming print jobs and send them to desired computers with printers attached.

I don't have any idea how to code this thing, and I don't have knowledge either, please help me with some resources, codes or sample projects or at least samples similar to this. Thanks


Solution

  • Looking back at my first answer in the light of your original question, I do no longer understand why I put so much emphasize on a "convert incoming job to an image"-stage. Probably because you had mentioned in one of your answers that you wanted a functionality similar to imageprinter.

    Anyway, since you now made clear that your main goal is to forward all incoming jobs to other computers (which have the real printers installed) -- this can also be achieved with:

    • a print queue with a PostScript driver
    • Ghostscript
    • RedMon as port monitor for the print queue
    • a DOS batch script

    The difference now is twofold:

    1. now you don't setup RedMon/Ghostscript in a way that converts incoming PostScript to an image format.
    2. now you setup RedMon to run Ghostscript in a way that routes the job through the real target queue 'sharedprintername' at 'remotecomputer' (including real driver).

    The Ghostscript command would be similar to:

      gswin32c.exe ^
       -dNOPAUSE ^
       -dBATCH ^
       -dQUIET ^
       -sDEVICE=mswinpr2 ^
       -dNoCancel ^
       -sOutputFile="%%printer%%\\remotecomputer\sharedprintername" ^
       -        ### <-- note this '-' !