We are using asp.net 2005(vb.net code) and in build crystal reports. We have a problem while printing report in landscape mode.
We have designed report in landscape and when we try to print it, the default is always shown as portrait in printer dialog.
Irrespective of what ever print orientation we have given in design time of the report, the print dialogue shown as default printer 'print orientation' settings. We tried changing report document properties to landscape through code but still it didn't work out.
We need the help urgently. Please help..........
The code is given below:
SqlConnection sqlCon = new SqlConnection("ConnectionString");
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
sqlCon.Open();
cmd.Connection = sqlCon;
cmd.CommandText = "Select * from OurTable";
da.SelectCommand = cmd;
da.Fill(ds, "Src");
ReportDocument rptDocument = new ReportDocument();
rptDocument.Load(@"D:\MySamples\CrystalReportSample\TestReport.rpt");
rptDocument.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
rptDocument.SetDataSource(ds.Tables[0]);
crViewer.ReportSource = rptDocument;
}