html - PHP: Adobe Reader can't open PDF files created with mpdf -
i'm using mpdf create pdf files on fly, , files open fine in browser adobe gives me error:
adobe acrobat reader dc not open 'example-filename.pdf' because either not supported file type or because file has been damaged (for example, sent email attachment , wasn't correctly decoded).
i looked @ other questions (another mpdf + adobe error), , checked out pdf in text editor. found first part of file looked this:
<!doctype html> <head> <title> capstonedb </title> %pdf-1.4 %âãÏÓ
after removed %pdf-1.4
(including tab), file opened fine in adobe, great, except need able generated pdfs open in adobe without manually fiddling code every time.
here's wrapper function calls mpdf html , css:
include('../mpdf/mpdf.php'); function user_download_pdf($html, $css_file, $filename) { $mpdf = new mpdf(); $stylesheet = file_get_contents($css_file); $mpdf->writehtml($stylesheet,1); $mpdf->writehtml($html,2); $mpdf->output($filename, "d"); }
i never feed mpdf full html page, h3 , 1 or more tables. maybe need giving mpdf entire html page, including <head>
, <body>
, etc? there way change mpdf configuration or way call mpdf in php rid of html junk @ beginning of pdf file that's gunking up?
place
ob_clean();
immediately before
$mpdf->output();
without mpdf includes website page html , not html want in pdf, because headers have been sent elsewhere in code. can mess pdf adobe won't open it.
Comments
Post a Comment