0

如何在我的本地网站(没有互联网)中实时预览 PDF 文件,该文件是保存在 Longblob 中的 PDF?我使用此脚本下载 PDF:

<?php
if(isset($_GET['id']))
{
include "../conn.php";
$query = "select * from file where id = '".$_GET['id']."'";
$result = mysql_query($query) or die (mysql_error);
$download = mysql_fetch_array($result);

$name = str_replace('%20', ' ',$download['file_name']);
$type = $download['file_type'];
$size = $download['file_size'];
$content = $download['file'];

header("Content-disposition: attachment; filename=\"".$name."\"");
header("Content-length: ".$size."");
header("Content-type: $type");
echo $content;
exit;
}
?>

我使用了几乎所有的开源 PDF 查看器插件,例如http://viewerjs.org,但未能显示想要的 PDF 文件。需要你们的帮助。。

4

1 回答 1

0

你应该有一个 pdf 插件,你应该使用如下代码:

header('Content-type: application/pdf');
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-Disposition: inline;filename='document.pdf'");
header("Content-length: ".strlen($binary_contents_from_database));
于 2014-03-21T08:30:22.493 回答