Home > Archive > Visual Basic Crystal Reports > January 2006 > Printing Crystal Report using vb.net code
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Printing Crystal Report using vb.net code
|
|
| trinnie 2006-01-24, 3:59 am |
| I have a web-application developed using vb.net, and report using
Crystal Report 11.
I have try to print using the method as shown below:
Dim prtdoc As New PrintDocument
Try
oRpt.PrintOptions.PrinterName =
prtdoc.PrinterSettings.PrinterName
oRpt.PrintToPrinter(1, False, 0, 0)
txtMessage.Text = MessageConstants.SUCCESS
Catch ex As Exception
txtMessage.Text = MessageConstants.FAILURE &
ex.Message
End Try
blnPrintClicked = False
End If
It give me errors:
Invalid printer specified: C:\doc~\Cr1.rpt
but the fact is i have a printer installed in my pc.
2. if i hardcoded my printer name, it would be not advisable to do so,
cuz i would never know that which printer my client would be using.
Anyone can help me on this, thanks in advance.
| |
| Richard Dudley 2006-01-25, 7:19 pm |
| If you're using a web applation, then the printer needs to be installed on
the server, not your PC, adn it needs to be installed under the user context
your application is using.
For a web application, your best bet is to have the report open as a PDF,
and let the user handle the printing.
"trinnie" <trinniewsc@gmail.com> wrote in message
news:1138086775.092577.286790@z14g2000cwz.googlegroups.com...
> I have a web-application developed using vb.net, and report using
> Crystal Report 11.
> I have try to print using the method as shown below:
>
> Dim prtdoc As New PrintDocument
>
> Try
> oRpt.PrintOptions.PrinterName =
> prtdoc.PrinterSettings.PrinterName
> oRpt.PrintToPrinter(1, False, 0, 0)
> txtMessage.Text = MessageConstants.SUCCESS
> Catch ex As Exception
> txtMessage.Text = MessageConstants.FAILURE &
> ex.Message
> End Try
> blnPrintClicked = False
> End If
>
> It give me errors:
> Invalid printer specified: C:\doc~\Cr1.rpt
> but the fact is i have a printer installed in my pc.
>
> 2. if i hardcoded my printer name, it would be not advisable to do so,
> cuz i would never know that which printer my client would be using.
>
> Anyone can help me on this, thanks in advance.
>
|
|
|
|
|