我正在尝试将PDF文档放在网页中。但是,不要在网页中查看这个页面,当这个页面被调用时,问问我们是否想要保存/下载一个,然后在打开打印机对话框的情况下在Adobe中打开它。ASP.NET在网页上查看PDF
的Javascript其背后调用该页面加载功能
window.open("http://localhost:1843/PrintDocument.aspx?DocumentId="+id+"&Year="+year+"&Location="+loc);
ASPX代码,页面加载功能:
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "Application/pdf";
string yr = Request.QueryString["Year"].ToString();
string Dyr = Convert.ToDateTime(yr).Year.ToString();
string Location = Request.QueryString["Location"].ToString();
string DocumentID = Request.QueryString["DocumentId"].ToString();
string PDFFile = string.Format(@"\\abc\def\pqr\{0}\{1}\{2}.pdf", Dyr, Location.Substring(0, 4), Location.Substring(4, 4));
//Response.AddHeader("content-disposition", "attachment; filename=document.pdf");
Response.WriteFile(PDFFile);
Response.End();
}
}
或更好的是当有一个破损的PDF安装。 – ggonsalv 2010-05-28 02:08:11