Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to print my Files found in my SPFolder directly to the Printer without recognizing the file type, so which Windows API to call and how to call it ? Also what's the process to launch the printing job when there are many files to print at the same time ?
Posted
Updated 29-May-18 3:00am
Comments
Sergey Alexandrovich Kryukov 16-Oct-12 13:00pm    
What makes you think that you really need it?
--SA
GLolita 16-Oct-12 13:02pm    
since my application will retrieve the docs from the server and will send those files to the client side where the printing operation wil take place, I thought since I'm on the server side and I have no idea about the printer I should be using low level printing services of gdi32.dll and winspool.drv
Sergey Alexandrovich Kryukov 16-Oct-12 13:04pm    
Just wrong motivation. It cannot really help you, but .NET printing will work.
--SA
Richard MacCutchan 16-Oct-12 14:44pm    
You cannot do it without recognising the file type as you will have no idea what to send to the printer. Some file types will have a registered print option in their file type set in the shell so you could try that, but you are still relying on the user setup. And you will still need the user to select the actual printer for each file.
Sergey Alexandrovich Kryukov 16-Oct-12 17:17pm    
It's a good point.
--SA

If you use C#, printing directly with Win32 API would be 1) awkward, hard to implement, 2) not platform-portable (in contrast to using CLI and .NET FCL — you would be able to run your code on a number non-Microsoft platforms). I see no situations where you can get any benefits of it. As most members also don't like waste their time on something which does not make sense or not really useful, you will need to provide a convincing motivation of what you want, but I don't think you can succeed.

—SA
 
Share this answer
 
Hello,

You can use spooler API. This articles helps you:

http://support.microsoft.com/kb/322091/en-us[^]
http://support.microsoft.com/kb/138594/en-us[^]

Regards,
Maxim.
 
Share this answer
 
This is what you're looking for:

C#
var processStartInfo = new ProcessStartInfo(filename)
{
    Verb = "Print",
    CreateNoWindow = true,
    WindowStyle = ProcessWindowStyle.Hidden
};
Process.Start(processStartInfo);
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 29-May-18 9:01am    
After almost 6 years?! Are you sure?
[no name] 18-Dec-22 7:18am    
Yes, thank you for checking up.

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