【发布时间】:2014-02-19 13:11:15
【问题描述】:
我想将返回 PDF 文件流的网页标题设置为:
public ActionResult PrintInvoice(long ID)
{
var data = db.Documents.Where(x => x.InvoiceNumber == ID);
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("~/Reports/InvoiceDocument.rpt"));
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return new FileStreamResult(stream, "application/pdf"); //For Showing PDF in Browser itself
}
我想在这个页面上设置标题。
如何设置此页面的标题。
目前页面上的标题如下图所示::
【问题讨论】:
-
使用@cubitouch 答案(这是正确的),您将无法更改标题,我认为没有办法做到这一点。您将得到的是该文件将在浏览器中打开,当您保存它时,它将获得您在
File()调用的第三个参数中指定的文件名。 -
这里有一篇文章再次说明你想要达到的目标是做不到的:forums.asp.net/t/1707949.aspx。解决方法在底部进行了说明:使用
IFRAME将 pdf 渲染到其中。 -
浏览器(至少 Chrome 和 Firefox)从 pdf 文档的标题元数据中设置页面标题。 w3.org/TR/WCAG20-TECHS/PDF18.html
标签: c# asp.net-mvc asp.net-mvc-3 web.config-transform