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

PHP:如何在浏览器中更改PDF的页面标题,php,html,pdf,Php,Html,Pdf,我这里有在浏览器中查看pdf文件的代码,但我找不到如何更改页面标题和标题栏。可以自定义标题吗 $file = "additionalInfo_content/QXp6dk3ZB1.pdf"; $fp = fopen($file, "r") ; $myFileName = 'test'; header("Cache-Control: maxage=1"); header("Pragma: public"); header("Content-type: application/pdf"); head

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

$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中的最后一个字符串,即qxp6d3zb1.pdf以及标题栏。我想更改我想要的标题

通常使用HTML
元素更改标题。查看非HTML文件时,它只显示文件名或内部PDF元标题(如果可用)

在将文件发送到浏览器之前,您必须更改文件的元数据。在其他方法中,有一种:

通过使用htaccess文件重写规则隐藏php处理文件,可以控制通过php加载pdf时显示的窗口标题。使用htaccess的示例 重写规则 ^上载/([^/]+)/([^/]+)/([^/]+)(/)?$/file.php?源=$1&file=$2&name=$3[NC,L,QSA]

  • 如果您的url是“https://example.com/uploads/files/QXp6dk3ZB1/myfilename.pdf,则可以提取文件qxp6d3zb1.pdf,但在浏览器窗口中显示干净的文件名“myfilename.pdf”

它将使用正确版本的pdfLib,请参阅