views:

80

answers:

3

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

+2  A: 

There is a commercial component that allows you to create virtual printers in windows. See http://www.colorpilot.com/emfprinterpilot.html

unclepaul84
Thank you very much for your response. At least now I know this kind of thing is practical.The commercial software is actually determining the printer and transfers a.ini file back to client so client itself sends the print job to the printer. But what i need is not that. I want to create the software so that it can accept the print job (EMF file) and then forward the print job (as a job of it's own) to a remote or local printer. Thanks for your response.
Zerone
I have found a similar software called "Image Printer" following is the link for thathttp://sourceforge.net/projects/imageprinter/http://code-industry.net/imageprinter.phpBut the Image Printer instead of forwarding the print job to a real printer; it converts it to any of image file formats (.jpeg bmp etc)I can't find the source code of this. Most of the functionality is similar to mine, only difference is it converts the Print to an image file format according to its settings while I need to forward the print job to a remote or local printer to print it on paper.Thanks for the comments.
Zerone
@Zerone: one very effective way to say "thank you" to people who help you here is to upvote their answers. Just click on the little upward pointing arrow at the top left of an answer...
pipitas
@Zerone: ...and, BTW, the source code for 'imageprinter' is here: http://sourceforge.net/projects/imageprinter/develop
pipitas
@pipitas: thank you I found the source code alright after the post, but I find it little difficult to understand, but sure some more trying will get me through.And thank you I appreciate your effort and time going through all my questions and pointing out the Vote Up! Didn't do much manipulating in this site coz i recently joined.
Zerone
@Zerone: did you also see that you (as the one who submitted a question) can award the best answer with an *accept* vote (on top of the 'upvote')?
pipitas
@pipitas: Yes and I did that for few of my questions. Thank you very much.
Zerone
+1  A: 

This can be done combining four ingredients in the right way:

  • a print queue setup with a PostScript printer driver, shared on the LAN;
  • Ghostscript (scroll down for fetching gs871w{32,64}.exe) to convert PostScript to image;
  • RedMon (download redmon17.zip) to serve as the 'printer port monitor';
  • a DOS batch file (or a C# program if you want) to do exactly what you want;

The printqueue will be using the 'Redirector Port Monitor' (RedMon) to channel the incoming PostScript jobs to a program/application/batchscript of your choice.

What's left to do is your job: write a simple program/application/batchscript which does three things:

  1. take the incoming PostScript as its input,
  2. call a Ghostscript commandline to convert input to the %imageformat% of your choice,
  3. and finally send the %imageformat% as jobs to a printer of your choice.

Here is a document that describes some of the basic need-to-know things regarding RedMon:


If you are a newbie to Ghostscript, you'll probably have the biggest problem with constructing a commandline that would do what you neeed. Here are some examples.

The first one converts data arriving at standard input (stdin, - at the end of the command) into single-page, black+white TIFF G4, with a resolution of 600dpi, where each page is a separate file, named page_001.tif, page_002.tif, etc.:

gswin32c ^
   -dBATCH ^
   -dNOPAUSE ^
   -dSAFER ^
   -sDEVICE=tiffg4 ^
   -r600x600 ^
   -sOutputFile=c:/path/to/output/page_%03d.tif ^
   -       ### <-- note this '-'!

Here is a Ghostscript commandline which would generate the same output, but this time as one single multi-page TIFF G4:

gswin32c ^
   -dBATCH ^
   -dNOPAUSE ^
   -dSAFER ^
   -sDEVICE=tiffg4 ^
   -r600x600 ^
   -sOutputFile=c:/path/to/output/multi_page_g4.tif ^
   -       ### <-- note this '-'!

Oh, you don't want black+white G4 TIFF, but colored TIFF, 32-bit CMYK? OK, use a different output device for Ghostscript:

gswin32c ^
   -dBATCH ^
   -dNOPAUSE ^
   -dSAFER ^
   -sDEVICE=tiff32nc^
   -r600x600 ^
   -sOutputFile=c:/path/to/output/multi_page_color.tif ^
   -       ### <-- note this '-'!

You want JPEG? Sorry, there is no such thing as multi-page JPEG. But single-page no problem:

set outputname=some-uniq-name && ^
gswin32c ^
   -dBATCH ^
   -dNOPAUSE ^
   -dSAFER ^
   -sDEVICE=jpeg ^
   -dJPEGQ=95 ^
   -r600x600 ^
   -sOutputFile=c:/path/to/output/%outputname%-page_%03d.jpeg ^
   -       ### <-- note this '-'!
pipitas
Thanks pipitas. Is there another easy way by using Microsoft Universal Printer Driver? I recently found out that information.
Zerone
@Zerone: No, using Microsoft Universal Printer Driver certainly is more difficult. You need to understand the MS source code, and you need to add your own source code to gain the features you want. My proposed solution can be scripted with a few lines of batch programming.
pipitas
Thanks a lot that clarifies lot of my troubles, now I can concentrate on developing using ghostscript. Well you provided me whole lot of information which I didn't find anywhere else.
Zerone
+1  A: 

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 '-' !
pipitas
Thank you very much pipitas, this is very helpful now I'm reading about it. The information you provided on converting printjobs to image formats is not wasted, coz i'm planning to save a jpeg picture of the print job in the computer running this software. So thanks for those details again.
Zerone
@pipitas: can you point me to any article or online resource on creating a PostScript Printer Driver for windows. As you educated me, now I need to build up the driver first. Since all these topics are very new it seems I have to learn a lot. Sorry to trouble continuously, thank you very much for all your help.
Zerone
@pipitas: I already found one resource.. let me know if you have any comments on this.http://www.stat.tamu.edu/~henrik/GSPSprinter/GSPSprinter.htmlThanks
Zerone
@pipitas: I followed the above link in my previous comment, downloaded the ghostscript 8.71 and redmon1.7. But according to the tutorial when I tried to add a redirecting port as RPT1: it says "Specified Port Cannot be Added" what can I do to this?
Zerone
@Zerone: My guess is that you already have a port named 'RPT1:'. Try a name of 'Redmon:', 'Zerone:', 'RPT2:' or whatever you want. -- Your 'RPT1:' has probably been installed by you before, or by some other software that uses RedMon. A PDF printer maybe?
pipitas
@pipitas: I tried different names but no use, it says "Specified port cannot be added". Seems I can't add a Redirected Port at all. Disabled the Windows Firewall and tried but same result.
Zerone
I created a new question. http://stackoverflow.com/questions/3433382/cant-add-new-redirected-port-in-windows-7-after-installing-redmon
Zerone
@pipitas: If you have any links to online tutorials or examples on how to create a postscript printer driver using redmon and ghostscript and handle print jobs through a c# application and to send them to desired printers; please let me know. Thanks
Zerone