在 url 使用 ironpdf 将 pdf 转换为 pdf 期间打开 pdf 而不保存

Open the pdf without saving it ,during url to pdf conversion using ironpdf

我正在使用 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);

尝试 Google 文档:

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

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

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

            //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