Pdf Crystal Report export
Hi,
I'm searching for help about exporting to pdf format a report in a Web Form. I followed typical indication found in the internet and in the book written by David McAmis, without a significative result.
I have a page with the CR ReportViewer, the CR ReportDocument, and a button vcomponents, last of which lauches the code for exporting to a pdf file. The pdf is generated, but is empty.
I got the following errors:
1- "Error while processing of the page. Insufficient numbers of operands".
2- "Unkknow token found: 0,05"
The file occupies 56 kb. Folder Permissions are ok. Credentials for the database are re-inserted.
Any help is welcome.
Here's the Web Form' code behind.
Thanks.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
namespace Accenture.IS_Italy.UI.Web.Report
{
/// <summary>
/// Summary description for ReportCRPage.
/// </summary>
public class ReportCRPage : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CRViewer;
protected System.Web.UI.WebControls.Button btnPdf;
protected CrystalDecisions.CrystalReports.Engine.ReportDocum ent CrystalDoc;
private void Page_Load(object sender, System.EventArgs e)
{
MyReport = <extract report business object from Session>;
this.CrystalDoc.Load(MyReport.HardCopyUrl);
this.CRViewer.ReportSource = this.CrystalDoc;
((TableLogOnInfo)this.CRViewer.LogOnInfo[0]).ConnectionInfo.Password = "pwd";
this.CRViewer.DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.CrystalDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocum ent();
this.CRViewer.Init += new System.EventHandler(this.Init_Report);
this.btnPdf.Click += new System.EventHandler(this.btnPdf_Click);
//
// CrystalDoc
//
this.CrystalDoc.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPa perOrientation;
this.CrystalDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize ;
this.CrystalDoc.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper;
this.CrystalDoc.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default;
this.CrystalDoc.InitReport += new System.EventHandler(this.CrystalDoc_InitReport);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnPdf_Click(object sender, System.EventArgs e)
{
DiskFileDestinationOptions dfdoReportFile = new DiskFileDestinationOptions();
ExportOptions crepExportOptions = CrystalDoc.FormatEngine.ExportOptions;
dfdoReportFile.DiskFileName = "C:\\Inetpub\\wwwroot\\<AppName>\\script\\Report\\ Pdf\\RepCR.pdf";
crepExportOptions.DestinationOptions = dfdoReportFile;
crepExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crepExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
TableLogOnInfo credentials = new TableLogOnInfo();
this.CrystalDoc.SetDatabaseLogon("USR","pwd");
this.CrystalDoc.FormatEngine.Export();
}
private void Init_Report(object sender, System.EventArgs e)
{
}
private void CrystalDoc_InitReport(object sender, System.EventArgs e)
{
}
}
}
|