SAP Knowledge Base Article - Public

1182305 - How to print report in portrait orientation at runtime with Crystal Reports XI R2


When attempting to print report using Crystal Reports XI R2 in Visual Studio .Net 2005 application, an error occurs:
"Printer is not defined."


Incorrect code is being used to print the report.



To print report with orientation and print name defined use the following code:


Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Partial Class _Default

    Inherits System.Web.UI.Page

    Dim crReportDocument As ReportDocument

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 

crReportDocument = New ReportDocument()


crReportDocument.PrintOptions.PaperOrientation = PaperOrientation.Portrait

crReportDocument.PrintOptions.PaperSize = PaperSize.PaperA4

crReportDocument.PrintOptions.PaperSource = PaperSource.Auto

crReportDocument.PrintOptions.PrinterName = "Name of the printer"

crReportDocument.PrintToPrinter(1, True, 1, 1)

CrystalReportViewer1.ReportSource = crReportDocument

    End Sub

End Class


Print, orientation, Crystal Report XI, Printer not defined net 2005 , KBA , BI-DEV , Business Intelligence Software Development Kits (SDKs) , How To


SAP Crystal Reports XI ; SAP Crystal Reports XI R2