0

i want to download a html page into a pdf file. i'm using Codeigniter.

This is my code:

<?php
if($type==0)//excel
{
    $mime="vnd.ms-excel";
    $format=".xls";
}
else if($type==1)//pdf
{
    $mime="pdf";
    $format=".pdf";
}

header('Content-Type: application/'.$mime.'');
header('Content-Disposition: attachment; filename="Placeout'.$format.'"');
header("Content-Transfer-Encoding: binary");
header('Accept-Ranges: bytes');
/* The three lines below basically make the download non-cacheable */
header("Cache-control: private");
header('Pragma: private');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
?>

<html>
<body>
..........
</body>
</html>

When i export into an excel file, it works. But when i'm exporting into a pdf file, it download the file but i can't open the file. when i open the file it shows a message: This is the message from adobe reader...

Also, can you explain the last three header line(the non-cacheable thing). Thank you for your answer..

Krisnadi
  • 641
  • 1
  • 10
  • 23
  • Possible duplicate of [PDF Export in php](http://stackoverflow.com/questions/10496122/pdf-export-in-php) – guychouk Nov 09 '15 at 09:37
  • @GSWV : i want to export without any plugin. – Krisnadi Nov 09 '15 at 10:01
  • You can't, even in the official PHP manual they recommend using PDFlib which is a PECL extension not bundled with PHP, for more information use [this](http://php.net/manual/en/pdf.installation.php) link. – guychouk Nov 09 '15 at 10:19
  • there are a good way to put html page into pdf file, event you put into pdf the format will change. but you can put into doc file. – Kazakh Aug 05 '16 at 09:19

0 Answers0