PHP:如何在浏览器中更改PDF的页面标题

PHP:如何在浏览器中更改PDF的页面标题

问题描述:

我这里有代码可在浏览器中查看pdf文件,但找不到如何更改页面标题和标题栏.可以自定义标题吗?

I have codes here to view pdf file in browser but I can't find how to change the page title and the title bar. Is this possible to customize title?

$file = "additionalInfo_content/QXp6dk3ZB1.pdf";
$fp = fopen($file, "r") ;
$myFileName = 'test';
header("Cache-Control: maxage=1");
header("Pragma: public");
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=".$myFileName."");
header("Content-Description: PHP Generated Data");
header("Content-Transfer-Encoding: binary");
header('Content-Length:' . filesize($file));
ob_clean();
flush();
while (!feof($fp)) {
   $buff = fread($fp, 1024);
   print $buff;
}
exit;

页面标题显示了URL中最后一个字符串是QXp6dk3ZB1.pdf以及标题栏.我想根据自己想要的标题进行更改

The page title show's what the last string in my URL which is the QXp6dk3ZB1.pdf as well the title bar. I want to change it on what my desire title

通常使用HTML <title>元素更改标题.查看不是HTML的文件时,它仅显示文件名或内部PDF元标题(如果有).

The title is normally changed using the HTML <title> element. When viewing a file that is not HTML, it just displays the filename, or the internal PDF meta-title, if available.

您必须先更改文件的元数据,然后再将其发送到浏览器.除其他方法外,还有以下一种方法: http://php.net/manual/en/function.pdf- set-info.php

You would have to alter the meta data of your file before sending it to the browser. Among other methods, there's this one: http://php.net/manual/en/function.pdf-set-info.php