我用R&适用于php的操作系统pdf类,一切正常,打开php,浏览器显示pdf文件。但我的客户刚刚告诉我,他们需要在一个小的iframe中显示它,所以他们要求我强制下载,这样用户就不会得到这个缩小到500px的字母大小的pdf文件。我对R&操作系统pdf类,但我找不到这样做的方法,不是eve用这个代码
`<?php
header('Content-disposition: attachment; filename=huge_document.pdf');
header('Content-type: application/pdf');
readfile('huge_document.pdf');
?>`
也许我只是不知道该把代码放在哪里,有什么想法吗?
试试这样的Sussie:
example.php
<?php
error_reporting(0);
$text = 'Example text';
include './src/Cezpdf.php'; // http://pdf-php.sourceforge.net/
$pdf = new Cezpdf();
$pdf->ezText($text,50);
$pdfcode = $pdf->ezOutput(1);
file_put_contents('huge_document.pdf', $pdfcode);
if (isset($_GET['d']) && $_GET['d']){
header('Content-disposition: attachment; filename="huge_document.pdf"');
header('Content-type: application/pdf'); // or 'application/octet-stream'
header('Content-Encoding: gzip');
while (@ob_end_clean());
ob_start('ob_gzhandler');
readfile('huge_document.pdf');
exit;
}
?><!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p><a href="?d=download">Download</a></p>
<iframe src="file.pdf" width="500" height="700"></iframe>
</body>
</html>