<small id='xn9il'></small><noframes id='xn9il'>

    1. <legend id='xn9il'><style id='xn9il'><dir id='xn9il'><q id='xn9il'></q></dir></style></legend>
      <i id='xn9il'><tr id='xn9il'><dt id='xn9il'><q id='xn9il'><span id='xn9il'><b id='xn9il'><form id='xn9il'><ins id='xn9il'></ins><ul id='xn9il'></ul><sub id='xn9il'></sub></form><legend id='xn9il'></legend><bdo id='xn9il'><pre id='xn9il'><center id='xn9il'></center></pre></bdo></b><th id='xn9il'></th></span></q></dt></tr></i><div id='xn9il'><tfoot id='xn9il'></tfoot><dl id='xn9il'><fieldset id='xn9il'></fieldset></dl></div>
    2. <tfoot id='xn9il'></tfoot>

          <bdo id='xn9il'></bdo><ul id='xn9il'></ul>

        以 PDF 格式生成 Crystal 报告...如何在新标签页或新页面中打开?

        时间:2023-07-09

          <small id='JyPb5'></small><noframes id='JyPb5'>

          <tfoot id='JyPb5'></tfoot>

            <tbody id='JyPb5'></tbody>
            <bdo id='JyPb5'></bdo><ul id='JyPb5'></ul>

            • <legend id='JyPb5'><style id='JyPb5'><dir id='JyPb5'><q id='JyPb5'></q></dir></style></legend>

              <i id='JyPb5'><tr id='JyPb5'><dt id='JyPb5'><q id='JyPb5'><span id='JyPb5'><b id='JyPb5'><form id='JyPb5'><ins id='JyPb5'></ins><ul id='JyPb5'></ul><sub id='JyPb5'></sub></form><legend id='JyPb5'></legend><bdo id='JyPb5'><pre id='JyPb5'><center id='JyPb5'></center></pre></bdo></b><th id='JyPb5'></th></span></q></dt></tr></i><div id='JyPb5'><tfoot id='JyPb5'></tfoot><dl id='JyPb5'><fieldset id='JyPb5'></fieldset></dl></div>

                  本文介绍了以 PDF 格式生成 Crystal 报告...如何在新标签页或新页面中打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我编写了一个代码来生成 PDF 格式的 Crystal Reports 报告...但它在用户搜索并单击按钮的同一页面中打开...有任何方法可以在新页面中打开 PDF标签或页面?

                  I did a code to generate a report of Crystal Reports in PDF...But it opens in the same page of the user did a search and clicked in the button...Have any ways to open the PDF in a new tab or page ?

                  我的代码是:

                  private void OpenPDF()
                  {
                      ReportDocument Rel = new ReportDocument();
                      Rel.Load(Server.MapPath("../Reports/Test.rpt"));
                      BinaryReader stream = new BinaryReader(Rel.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
                      Response.ClearContent();
                      Response.ClearHeaders();
                      Response.ContentType = "application/pdf";
                      Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
                      Response.Flush();
                      Response.Close(); 
                  }
                  

                  感谢您的帮助!

                  推荐答案

                  在最简单的解释中,要打开一个新窗口或选项卡,页面的超链接应该将 target 属性设置为_blank".

                  In its most simplest interpretation, to open a new window or tab, the hyperlink to the page should have the target attribute set to "_blank".

                  <a href="GeneratePDF.aspx" target="_blank">Link to open PDF in new window</a>
                  

                  或者您可以创建一些 Javascript 来打开一个新窗口.确保在页面某处调用 Javascript 函数.

                  Or you could create some Javascript that opens a new window instead. Make sure you call the Javascript function somewhere on the page.

                  <script type="text/javascript">
                  function loadPDF() {
                     window.open('GeneratePDF.aspx','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
                  }
                  </script>
                  

                  或者此代码将通知网络浏览器该文件是下载文件(而不是在浏览器窗口中查看的页面).我认为这是最好的方法,因为用户可以选择打开或保存 PDF.所以这并不能满足您的要求,但您可能认为它更好.

                  Or this code will inform the web browser that the file is a download (rather than a page to view inside the browser window). I think this is the best approach because the user gets the choice of Opening or Saving the PDF. So this does not do what you're asking for, but you might think it's better.

                  private void OpenPDF(string downloadAsFilename)
                  {
                      ReportDocument Rel = new ReportDocument();
                      Rel.Load(Server.MapPath("../Reports/Test.rpt"));
                      BinaryReader stream = new BinaryReader(Rel.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
                      Response.ClearContent();
                      Response.ClearHeaders();
                      Response.ContentType = "application/pdf";
                      Response.AddHeader("content-disposition", "attachment; filename=" + downloadAsFilename);
                      Response.AddHeader("content-length", stream.BaseStream.Length.ToString());
                      Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
                      Response.Flush();
                      Response.Close(); 
                  }
                  

                  这篇关于以 PDF 格式生成 Crystal 报告...如何在新标签页或新页面中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C#水晶报表问题和图表? 下一篇:命名空间“CrystalDecisions.Web"中不存在类型或命名空间名称“CrystalReportVi

                  相关文章

                  <i id='tj5vI'><tr id='tj5vI'><dt id='tj5vI'><q id='tj5vI'><span id='tj5vI'><b id='tj5vI'><form id='tj5vI'><ins id='tj5vI'></ins><ul id='tj5vI'></ul><sub id='tj5vI'></sub></form><legend id='tj5vI'></legend><bdo id='tj5vI'><pre id='tj5vI'><center id='tj5vI'></center></pre></bdo></b><th id='tj5vI'></th></span></q></dt></tr></i><div id='tj5vI'><tfoot id='tj5vI'></tfoot><dl id='tj5vI'><fieldset id='tj5vI'></fieldset></dl></div>
                1. <small id='tj5vI'></small><noframes id='tj5vI'>

                      <legend id='tj5vI'><style id='tj5vI'><dir id='tj5vI'><q id='tj5vI'></q></dir></style></legend>
                    1. <tfoot id='tj5vI'></tfoot>

                      • <bdo id='tj5vI'></bdo><ul id='tj5vI'></ul>