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

cvb.net

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

Best Answer

Use this code to know the installed printers

Imports System.Drawing
Imports System.Drawing.Printing

and this code on the load function... you will fill a combobox with the printers and their names correctly, and then use your code

For Each Printer In PrinterSettings.InstalledPrinters
    cmbPrinters.Items.Add(Printer)
Next
Related Topic