【问题标题】:Open the pdf without saving it ,during url to pdf conversion using ironpdf在使用 Ironpdf 将 url 转换为 pdf 期间打开 pdf 而不保存它
【发布时间】:2018-03-30 07:53:22
【问题描述】:

我正在使用 ironpdf 将 url 转换为 pdf。转换成功,但我必须将文档保存在某个位置。是否可以只显示为内存流或字节数组?

            string authority = HttpContext.Current.Request.Url.Authority;
            string val = "http://"+authority + "/Report/PrintReport.aspx?ID=" + vciInfoReportid;
            string fileName = "url.pdf";
            string fileloc = HttpContext.Current.Server.MapPath("~/"+fileName);
            Renderer.RenderUrlAsPdf(val).SaveAs(fileloc);

【问题讨论】:

    标签: c# pdf pdf-generation


    【解决方案1】:

    我找到了解决方案。它有一个内置的方法

                //Conversion of the ASPX file into PDF
    
                MemoryStream rend=Renderer.RenderUrlAsPdf(val).Stream;
    
                HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");
    
                // let the browser know how to open the PDF document, attachment or inline, and the file name
                HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("{0}; filename=Print.pdf; size={1}",
                  "attachment", rend.Length.ToString()));
    
                // write the PDF buffer to HTTP response
                HttpContext.Current.Response.BinaryWrite(rend.ToArray());
    
                // call End() method of HTTP response to stop ASP.NET page processing
                HttpContext.Current.Response.End();
    

    更多信息可以在这个ASPX to PDF Tutorial找到

    【讨论】:

      【解决方案2】:

      试试 Google 文档:

      在谷歌查看器中打开您的 pdf,无需下载。

      http://docs.google.com/viewer?url=http://"+authority + "/Report/PrintReport.aspx?ID=" + vciInfoReportid
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-10-30
        • 1970-01-01
        • 1970-01-01
        • 2016-07-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多