How to printing crystal report directly to network printer in Vb.net or C#.net in Windows Applications


Question

I have written the following code as,

        Dim report As New ReportDocument
        report.PrintOptions.PrinterName = "\\network\printer"
        report.Load(CrystalReportName.rpt, OpenReportMethod.OpenReportByDefault)
        report.PrintToPrinter(1, False, 0, 0)

when i am trying to run this code , it shows the error message as "Invalid Printer Specified". If i give the local printer name, it is working fine. But i can't able to print the crystal report directly to the network printer. Kind help needed. Thanks in advance.

Sivakumar.P

1
2
3/25/2009 5:19:56 AM

Accepted Answer

May be the printer name is wrong.

Please use the following code to debug what name is coming while choosing the network printer

http://www.codeproject.com/KB/printing/printtoprinter.aspx

and then assign proper name.

Still if incase it did not work out, there might be a permission issue then look at

http://forums.asp.net/t/1383129.aspx

Best of luck,.

1
3/25/2009 5:52:42 AM

In case anyone else still has this problem:

In the crystal report document you are trying to print, go to:

Design --> Page Setup

A default printer not installed on your server side may have been selected. Remove or replace it and save the document. Then run your .Net code to set the printer dynamically if you want.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon