Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing directly to printer 1

Status
Not open for further replies.

onedunpark

IS-IT--Management
Jan 17, 2003
19
GB
Hi,

This will no doubt be embarrasingly easy, but I'm stumped.

VS 2003 Pro/CR 11 Developer Edition

Am printing reports to a Report Viewer and then from there my users can print/export as appropriate.

How do/can I bypass the viewer form entirely and (based on their choice from my calling form) simply print directly to the default printer, or for that matter export directly to PDF if preferred.

I'm not sure other technical details are required as this is such a fundamental question, but am happy to post whatever code is required, as necessary.

Thanks in anticipation.

Steven
 
Found the answer separately from MisterMo's suggestion.

However, many thanks for their input which is greatly appreciated.

For interests sake, in basic terms, here is the solution I came up with

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Dim strReportname As String = "myreport.rpt"

If Me.objPrintDest = MyEnum.PrintDestination.Printer Then
strReportname.PrintOptions.PrinterName = “<printerName>”
strReportname.PrintToPrinter(1, True, 1, 1)
End If

If Me.objPrintDest = MyEnum.PrintDestination.PDF Then
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions

crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = "C:\exported.pdf"

crExportOptions = report.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With

strReportname.Export()

End If

Hope that helps someone else.

Steven
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top