我正在用这个来输出一个pdf文档。
$response = new \Symfony\Component\HttpFoundation\Response(file_get_contents($thefile), 200, [
'Content-Description' => 'File transfer',
'Content-Disposition' => 'filename="' . $filename . '"',
'Content-Transfer-Encoding' => 'binary',
'Content-Type' => 'application/pdf',
]);
unlink($thefile);
$response->send();
在生成的页面中,标题是指向页面的链接。
我怎样才能自定义标题?
你必须在pdf中包含标题。
我只需要从一个脚本中生成pdf作为iframe的src!
这样就可以保留标题了!
<head>
<title>THE TITLE</title>
</head>
<body>
<iframe src="process.php"></iframe>
</body>
</html>
或者我可以用ajax的方式来生成php脚本,然后用一个容器元素(比如div)来返回结果。