Have a look at PrintDocument, its the way to go when printing in c#. To quote from the msdn site. Typically, you create an instance of the PrintDocument class, set properties such as the DocumentNameand PrinterSettings, and call the Print method to start the printing process. Jan 26, 2014 Hi sekhar, Thanks for helping. But I have to print pdf, with url sent by the server. So it's a http url like 'http://localhost/ptwamp/test.pdf'. There are issues with credentials that you could solve by impersonation or elevating rights of the user the web app is running under. However, we did it by adding the network printer as a printer on the server (add printer dialogue on server) and having the job sent to that printer. We used the Printing.PrintDocument like so (Code in VB). Public Class SpecialReportPrintJob Inherits Printing.PrintDocument Protected Overrides Sub OnBeginPrint(ByVal ev as Printing.PrintEventArgs) MyBase.OnBeginPrint(ev) Me.PrinterSettings.PrinterName = 'PrinterNameUsedOnServer' 'setup rest of stuff. End Sub End Class 'And we then call it like so Dim printSpecialReport as new SpecialReportPrintJob() printSpecialReport.Print(). I have a Windows server running an ASP.NET application and a local printer connected to this machine. I need to print some documents from the server-side code. So far I know, there's no managed API in.NET that is supported on server-side (service). • System.Printing namespace - is part of the WPF and is not supported to run on server-side as it may produce run-time exceptions (checked on msdn) • System.Drawing.Printing - is part of the WinForms and also not supported to run on server-side (checked on msdn) The same problem was elaborated with help of Microsoft back in 2009 and the solution was to use an unmanaged XPS Print API as the only supported way back in that time. Problem described and solution with example posted is here: However nowadays this is a problem as the XPS Print API is marked as not supported and may be unavailable in the future (). So, what is the supported way of printing from the server-side code? It looks like there are more Win32 APIs that could be probably used, but there's no info on the web and it would probably be a nightmare. Commercial solutions are accepted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2018
Categories |