Crystal Report打印功能在部署后无效?

时间:2010-06-06 07:35:55

标签: asp.net visual-studio-2008 deployment crystal-reports

我正在使用水晶报告来构建报告,开发过程中一切正常 但在部署网站后,打印功能无效。

我使用_rptDocument.PrintToPrinter(1,false,0,0);打印报告。

我尝试了两种方法来部署网站

  1. 正常发布选项。
  2. Web部署项目。
  3. 但是我得到了相同的输出,打印功能不起作用 另外,我试图设置默认打印机,这也不起作用。

    有什么想法吗?

2 个答案:

答案 0 :(得分:2)

在网络服务器上打印不是一个好主意。应该怎么办?用户在您的服务器打印机上打印?使用CR创建PDF。将它们传递给您的客户。他们可以使用本地打印机。

答案 1 :(得分:1)

试试这个: - 创建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