Frage

I made a dynamic pdf file using R&OS pdf class for php and everything works fine, you open the php an the browser displays the pdf file. But my client just told me they need to display it inside a small iframe, so they asked me to force it to download so the user doesnt end up with this letter size pdf file shrinked down to 500px. I'm not that familiar with the R&OS pdf class but I couldn't find a way to do this, not eve with this code

`<?php
header('Content-disposition: attachment; filename=huge_document.pdf');
header('Content-type: application/pdf');
readfile('huge_document.pdf');
?>`

maybe i just didn't know where to place the code properly, Any ideas?

Keine korrekte Lösung

Andere Tipps

Try something like this 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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top