Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to print directly to a network printer from my desktop. Where can i find examples? I have done this a while back but cannot recall. Thank you.

[EDIT — moved from "solution" — SA]

That's not even the half of it. I will need to actually hardcode the pcl codes to send some data to a printonix printer with forms preprinted where i have to place the data exactly in certain locations. Right now, i just want to be able to print directly to a printer on the network. I know windows had some api's that allowed a user to select the printer, but if i am going to directly access the printer i wonder if i need to use sockets.
Posted
Updated 12-Mar-12 13:40pm
v2

Look at any more or less advanced text editor, graphic editor, Web browser or IDE. Do they ever have anything special to print using a network printer? I would say, never. They just print using a printer selected by the user, suggesting the default printer first, it any is available. You should do this, too, unless you want to scare off your users by one or another kind of ad-hoc functionality.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 12-Mar-12 19:32pm    
5'ed!
Sergey Alexandrovich Kryukov 12-Mar-12 19:39pm    
Thank you, Espen.
--SA
El_Codero 12-Mar-12 21:23pm    
A 5 star advice.
Sergey Alexandrovich Kryukov 12-Mar-12 21:39pm    
Thank you, Björn.
--SA
ProEnggSoft 27-Mar-12 9:13am    
Good advice. +5
You need to install the printer driver, and it's likely you'll find it here:
http://www.printronix.com/products/drivers.aspx#2147483655[^]

Once you have installed and configured the driver for your printer you can get a handle to the printer using the OpenPrinter[^] function.

You can get a list of available printers using the EnumPrinters[^]


You can use the WritePrinter[^] function to send data directly to the printer, but it's usually easier to use GDI[^] or GDI+.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Abhinav S 26-Mar-12 21:51pm    
5!
Espen Harlinn 27-Mar-12 5:27am    
Thank you Abhinav!
ProEnggSoft 27-Mar-12 9:14am    
+5
Espen Harlinn 27-Mar-12 9:15am    
Thank you :-D
Thank you Espen. I appreciate the feedback on the windows APIs, that's one of the things i need, i finally found an application i wrote 7 years ago but this is great, thanks a lot. The printer is already in production and this was being done by a mainframe which sent some file to a dropzone and the people doing the printing would pick it up and send it to the printer itself. They just want to replace the mainframe until the pre-formatted pages run out then they will move to some other printer and probably will use something like adobe live cycle or jasper if we go with java.
 
Share this answer
 
Comments
Espen Harlinn 13-Mar-12 14:52pm    
Glad I could be of some assistance :-D
In the future it would be better if you used the 'Have a Question or Comment?' butten to leave a message for me or the other people on the Q&A forum as this gets routed to our emails. Anyway, hope it works out well ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900