Link to home
Start Free TrialLog in
Avatar of amitd
amitd

asked on

Pseudo Printer name

When one selects to print from an application like MS Word, he gets the list of printers he can fire output to. I want to create my own Pseudo printer which capture the output from the application which fires the printout and redirect it to a particular port in particular machine.

1. How does one list ones own Pseudo printer name in the list of printers?
2. How will I capture the output from the application that fires the output to my Pseudo printer?
3. How do I send the output to a port of different machine?

For example,
Microsoft Fax also is listed in the list of printers when one selects the print option. Though from Application (like MS word) point of view it is a printer, but actually it is not a printer. It sends the output to a FAX machine.

My printer name should be like Microsoft Fax but the output should be send to a port in some other machine.

Please provide the code?
Avatar of DanRollins
DanRollins
Flag of United States of America image

This requires writing a printer device driver, and device-driver programming usually considered to be one of the most difficult tasks in Windows.

Consider that the "output" is not a simple stream of data -- it depends on the capabilities of the printer.  Example:  Microsoft Fax renders the page in an oddball 200x100 resolution because that is what most fax machines expect.  It generates a bitmap of each page at the proper resolution, then schedules delivery of that data later.  Contrast with a Postscript printer driver which sends strings of text (Postcript language commands and data) to a printer.

Would you be interested in a way to generate a file that contains the text in a document (no graphics or font control at all)?

You can also use Adobe Acrobat to output.  Given the resulting pdf file -- you could transfer that anywhere.

-==-=-=-=-=-=-=-=-=-=-=-=-=-

What is your actual goal?  Why do you want to do this?

I ask these questions because there may be other ways to accomplish your *actual* goal.  Writing a printer driver is too hard.
 
-- Dan
Avatar of amitd
amitd

ASKER

This is the requirement I cann’t change it!!. As of now plain text output will do. My main goal is that the “Pseudo printer name” should be visible to the Application (Such as MS Word) and I should get the fired output from the Application.
DanRollins >>What is your actual goal?  Why do you want to do this?

amitd >>This is the requirement I cann’t change it!!.

Almost nobody ever actually answers that question!  In the few cases where the person wrote up a paragraph describing their actual goal, I found simpler, acceptable ways to do what they needed done.  It is almost comical.  Why not tell me about your actual goal?

>>As of now plain text output will do

Follow these steps:
1) Use Control Panel and open the Printers page.
2) Double-click  the Add Printer icon
3) select Local printer and click [Next]
4) Scroll down in the Manufacturers list and select Generic
5) Click Next to create the Generic / Text only printer
6) When you get to the Available Ports screen, select File: Creates a file on disk

7) next page, set the name to TheMagicPrinter
8) skip the test page and click [Finish]

9) Back in the Printers window, right-click the new printer and select properties

10) under the Details tab, click [Add Prot...]
12)Slect Other and click [OK]
13) in the Port Name box that pops up, enter:
  c:\windows\temp\TheMagicFile.txt
And click [OK] until you are out of the dialogs.

Now a printer named TheMagicPrinter will appear in the list of availble printers.  When selected, the printed output will go to a file named c:\windows\temp\TheMagicFile.txt

Your program can then read that file and do whatever it wants with it.

-- Dan
Avatar of amitd

ASKER

Sorry for the late reply. “The plain text output” was really helpful for the demo, which I had to give, thanks for that.

>> Why not tell me about your actual goal?

I am not hiding my goal. This is the requirement given to me. I don’t have any more details. If writing device driver is the solution PLEASE provide the same.
Avatar of amitd

ASKER

Dan,

To add, to my previous comment.

If your "Generic printer" or some other printer. Captures any printout (Text/Graphics/non-Text) fired to it and puts it in a file that will do.

Thanks again,

Amit
Avatar of amitd

ASKER

I want to correct myself; I have been just informed that printout shouldn't be sent to a file. I am sorry for that...
>>I am not hiding my goal. This is the requirement given to me. I don’t have any more details.

Tell your boss (or professor, or wife, or who ever forced this requirement upon you) that you need additional details in order to implement a solution.  I would never take on a consulting job given the bare description that  you have provided to me  why? It is an open-ended project.  Virtually any work done on it would be unsatisfactory and "wrong" in the eyes of the client.  

I would ask the client to specify *exactly* what he wanted and why he wanted it.  I suggest that you do the same.

-- Dan
hi amitd,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
Avatar of amitd

ASKER

Hi,

I have got the whole requirement, which is as follows,

1) Capture the print out fired from any application on the PC.
2) Re-direct it to a printer server (via Internet). This server can be any where in the world.
3) The printer server job is to send the print out to a printer in its local area network.

Basically I have to fire a print out to a printer anywhere in the world.

Please suggest how to accomplish this job. Also, if possible provide the code.


Thanks,

Amitd.
Why didn't you say so?  The printer just needs to be shared as an internet printer and set up to accept a TCP/IP and/or HTTP connection.

http://support.microsoft.com/support/kb/articles/Q248/3/44.ASP

http://support.microsoft.com/support/kb/articles/Q248/3/44.ASP

-- Dan
Avatar of amitd

ASKER

For that the printer has to be IPP compliant. We are doing it for any printer.
Good luck in your endeavor!  If you find a way to print to my printer, please don't.

Here's what to do:  Get Adobe Acrobat, professional version.  Then you can print to the "Acrobat printer" to output a PDF file.  Then you can email that file or publish it on a web page so that anybody on the Internet can print it out (they may need to download the Acrobat Reader).  This is a close as you will ever get to realizing the stated goal.

-- Dan
Avatar of amitd

ASKER

The goal is to send the output to the printer server. This printer server will print it to the printer. Obviously I should be able to connect to this printer server via Internet.

Therefore the first thing, which I have to do, is to capture the output from the application and second send it to printer server.

I have already started with writing mini-driver. Am I on the right track? Is there a better way?

As of now I am successful in installing the printer on the machine. I am struggling to find the GDI function that handles the captured print out.
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi amitd,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
Avatar of amitd

ASKER

Hi Dan,

No, Right now I am going thru the examples which you had mentioned earlier. I will get back to you soon.

amit
Avatar of amitd

ASKER

Hi Dan,

I was able to create the printer driver and list the printer in the list of printers. But still I am not able to capture the print out. I have added OutputChar Call-back function in my code but that is never called (I have initialised the CUSTOMDATA structure with the Call-back function). Is this the correct Callback function to capture the output? If yes, what are the settings I have to do so that it is called, if no, then what is the right callback function and what are the settings that I have to do for that?

--amitd
Avatar of amitd

ASKER

Done it !!!
Thanks a lot for the samples.
Hai amit,
   can u pls tell me how done this , with clearly, How u caputred the print job? How u used ipp for internet printing? .
With regards
Jose
That's why I make the big bux -- I overcharge for very simple projects. Thanks for the points :-)

-- Dan
Avatar of amitd

ASKER

Take the TTY driver sample. In that there is a function "DevExtTextOut" the fifth parameter "lpStr" gives you the text to be printed.