Live Chat Icon For mobile
Live Chat Icon

How do I print a document using .NET?

Platform: WinForms| Category: General

This can be done using the Process class and specifying the verb as ‘Print’. This is the equivalent of right clicking and selecting print in the windows shell. Here is the code snippet that prints documents like MS Excel, MS Word, pdf etc..


// In C#.NET
//Print an Excel document
Process pr = new Process();
pr.StartInfo.Verb = 'Print';
pr.StartInfo.FileName = 'Sample.xls';
pr.Start();

’ In VB.NET
’Print an Excel document
Dim pr As Process =  New Process() 
pr.StartInfo.Verb = 'Print'
pr.StartInfo.FileName = 'Sample.xls'
pr.Start()

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.