如何在我的本地网站(没有互联网)中实时预览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;
}
?>
我几乎使用了来自http://viewerjs.org的所有开源PDF Viewer插件,但未能显示所需的PDF文件。需要你的帮助..
答案 0 :(得分: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));