【发布时间】:2016-04-25 17:51:17
【问题描述】:
我有一个在新浏览器选项卡中显示 PDF 的操作。
public ActionResult Print()
{
var cd = new ContentDisposition
{
FileName ="something.pdf",
Inline = true
};
Response.AppendHeader("Content-Disposition", cd.ToString());
return File(reportResponse.Data.Document, MediaTypeNames.Application.Pdf);
}
文件名工作正常。当我下载文件时,它的名称是我想要的“something.pdf”。
问题是当 google chrome 在新的浏览器选项卡中打开 PDF 时,它会将控制器操作名称(打印)显示为 PDF 的标题。这就是我想要改变的。我附上一张图片以供澄清。
查看代码: Url.Action("Print", "Controller", new { area = "Area" }), new { @target = "_blank" }
【问题讨论】:
-
浏览器(至少 Chrome 和 Firefox)从 pdf 文档的标题元数据中设置页面标题。 w3.org/TR/WCAG20-TECHS/PDF18.html
-
就我而言,PDF 是与其他内容内联显示的部分页面。在 MVC 中,标题设置为动作的名称。就我而言,我只是将动作名称更改为通用名称。仍然希望找到更好的解决方案。
标签: c# asp.net-mvc google-chrome pdf