Printing from ASP.NET to a network printer

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()

Leave a Comment