sivakumar
sivakumar

Reputation: 1577

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

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

Upvotes: 3

Views: 51006

Answers (6)

adnan umar
adnan umar

Reputation: 127

User 4 backslashes i.e \\ before Network and 2 backslashes i.e \ before printername

   \\\\[Network Address]\\[printer name]

Upvotes: 2

WARRIOR
WARRIOR

Reputation: 21

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.

Upvotes: 2

sujju
sujju

Reputation: 1

In ASP.Net, a simple and sweet solution consists in install same printer drivers(like hp or zebraa) including version in both server and clinet meachine it will work with @\\\ipaddress\printername.

Upvotes: 0

Rene Lapizco
Rene Lapizco

Reputation: 11

For anyone having a similar problem this can be a solution:

report.PrintOptions.PrinterName = "\\\\\\\\network\\\\printer"

Upvotes: 1

Fernando
Fernando

Reputation: 21

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

Upvotes: 2

lakshmanaraj
lakshmanaraj

Reputation: 4175

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,.

Upvotes: 1

Related Questions