我使用水晶报表来构建报表,开发时一切正常。
但是在部署网站后,打印功能不起作用。Crystal Report打印功能在部署后无法使用?
我使用_rptDocument.PrintToPrinter(1,false,0,0);打印报告。
我已经尝试了两种方法来部署网站
- 正常发布选项。
- Web部署项目。
但我得到了相同的输出,打印功能不起作用。
另外,我试图设置默认打印机,这也不起作用。
任何想法?
我使用水晶报表来构建报表,开发时一切正常。
但是在部署网站后,打印功能不起作用。Crystal Report打印功能在部署后无法使用?
我使用_rptDocument.PrintToPrinter(1,false,0,0);打印报告。
我已经尝试了两种方法来部署网站
但我得到了相同的输出,打印功能不起作用。
另外,我试图设置默认打印机,这也不起作用。
任何想法?
在Web服务器上打印并不是一个好主意。应该发生什么?用户在您的服务器打印机上打印?使用CR来创建PDF。将它们流到您的客户端。他们可以使用本地打印机。
试试这个: - 创建PDF和打开的浏览器选项... enter code here
string fname = "Report" + ".pdf";`enter code here`
//Create instance for crystal report Export option class
ExportOptions exprtopt = default(ExportOptions);
//create instance for destination option - This one is used to set path of your pdf file save
DiskFileDestinationOptions destiopt = new DiskFileDestinationOptions();
//Bind data in the crystal report first before export cystal report to PDF
ReportDocument RptDoc = new ReportDocument();
//Map your crystal report path
// RD.Load(Server.MapPath("~/CrystalReport2.rpt"));
//Set your crystal report datasource as dt
//Get path and assign into destination DiskFileName
destiopt.DiskFileName = Server.MapPath(fname);
exprtopt = RD.ExportOptions;
exprtopt.ExportDestinationType = ExportDestinationType.DiskFile;
//use PortableDocFormat for PDF data
exprtopt.ExportFormatType = ExportFormatType.PortableDocFormat;
exprtopt.DestinationOptions = destiopt;
//finally export your report document
RD.Export();
//To open your PDF after save it from crystal report
string Path = Server.MapPath(fname);
//create instance to client to open your pdf
WebClient client = new WebClient();
//Assign path to download pdf
Byte[] buffer = client.DownloadData(Path);
//metion content type as PDF and write
// Response.ContentType = "application/pdf";
//Response.AddHeader("content-length", buffer.Length.ToString());
//Response.BinaryWrite(buffer);
//======================================
Response.Write("<script>");
Response.Write("window.open('" + fname + "', '_newtab');");
Response.Write("</script>");
//===================================
IMTIYAZ
CR应该印上客户端的本地PC。 – Ahmed 2010-06-06 13:22:23
好的 - 我很喜欢使用PDF创建而不是打印的场景。您的代码是服务器端(ASP.NET)。没有关于服务器上的客户端打印环境的知识。 – 2010-06-07 06:07:40
+1,PDF生成正是我在这种情况下使用的。 – 2010-06-08 14:07:48