只是想知道是否可以使用称为使用 AJAX 的 Web 方法打开 PDF?要打开的文件存储在服务器上的临时目录中。
有人对如何实现这一目标有任何建议吗?
谢谢大家!
Just wondering if it's possible to open a PDF using a web method called using AJAX? The file to open is stored in a temp directory on the server.
Does anyone have any suggestions how this can be achieved?
Thanks all!
Oded 已经为您提供了最好的解决方案,但是,如果您仍然想这样做,这里是:
您可以使用此 jquery 插件。
您的网页将有一个超链接:
<a id="PrintAjaxReport" href="javascript:{}">Print report Ajax</a>
jQuery:
$(document).ready(function() { $("#PrintAjaxRepor").click(function() { $.download('PdfReport.aspx', "filename=mySpreadsheet", "POST"); }); });
PdfReport.aspx
public partial class PdfReport : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var pdfDocumentName = Request.Params["filename"].ToString() + ".pdf"; var myReport = "Razor Syntax Quick Reference.pdf"; var FileName = Path.Combine(Path.Combine(Server.MapPath("~"), "Temp"), myReport); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("content-disposition", "attachment; filename=" + pdfDocumentName); Response.TransmitFile(FileName); Response.End(); } }
您可以找到示例 (OpenPDFjQuery) "="">此处。
Oded has given you the best solutions but, if you still want to do it that way, here it goes:
You can use this jquery plugin.
Your web page would have an hyperlink:
You can find a sample (OpenPDFjQuery) here.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
Oded 已经为您提供了最好的解决方案,但是,如果您仍然想这样做,这里是:
您可以使用此 jquery 插件。
您的网页将有一个超链接:
jQuery:
PdfReport.aspx
您可以找到示例 (OpenPDFjQuery) "="">此处。
Oded has given you the best solutions but, if you still want to do it that way, here it goes:
You can use this jquery plugin.
Your web page would have an hyperlink:
jQuery:
PdfReport.aspx
You can find a sample (OpenPDFjQuery) here.