gpt4 book ai didi

php - 我想要在 PHP 中使用 header() 的自定义 < title >

转载 作者:可可西里 更新时间:2023-10-31 23:32:29 24 4
gpt4 key购买 nike

站在巨人的肩膀上,我已经成功地使用 header() 拼凑了一个脚本来在内网发布 pdf 文档,

我的显示代码:

<?php
require_once "includes/IniFile.php";
include_once "includes/process.php";
$MyData['ini'] = IniFile::getSettings();
foreach ( $_POST as $key => $value )
{ $fn = $key; }
$fn = str_replace("|sp|"," ",$fn);
$fn = str_replace("|dt|",".",$fn);
$ed = explode('!',$fn) ;
$MyData['ini']['pathMask'] = str_replace('|DEPT|', dptdir($ed[1], $MyData['ini'] ['departments']), $MyData['ini']['pathMask']);
$MyData['ini']['pathMask'] = str_replace('|FLDR|', subdir($ed[2], $MyData['ini'] ['folders']), $MyData['ini']['pathMask']);
$fn ='';
$file = $MyData['ini']['pathMask'].$ed[0];
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="'.$fn.'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
@readfile($file);
?>

一切正常,但我希望包含 .pdf 的新页面有一个与要发布的文档名称相对应的 <title>。

这可能吗?

谢谢 - 克里斯。

最佳答案

您应该呈现一个普通页面并将 PDF 嵌入到 iframe 中,而不是丢弃标题。通过这种方式,您可以拥有自己的标题,并且 PDF 仍然是内联的。

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My great title for the PDF</title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
border: 0;

height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: 0
}
</style>
</head>

<body>

<iframe src="yourpdfname.pdf"></iframe>

</body>
</html>

关于php - 我想要在 PHP 中使用 header() 的自定义 < title >,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14696017/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com