PHP:如何在浏览器中更改PDF的页面标题 [英] PHP : How to change page title of PDF in browser

查看:355
本文介绍了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

这篇关于PHP:如何在浏览器中更改PDF的页面标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆