DomPDF Zend not executing PHP? -
this controller function not generate right pdf problem.
this generate static html pdf requirement create pdf on dynamic created html.
$archive_msgs = $this->getrequest()->getpost('ids'); $archive_ids = explode(",",$archive_msgs); $ul = '<ul>'; if(!empty($archive_ids)){ foreach($archive_ids $archive){ if(trim($archive)!=''){ $msgdata = $this->getquerydatawithprimary('message', 'msgid', $archive); $dec_data = base64_decode($msgdata[0]['message']['s']); $arr_data_com = explode(",,", $dec_data); $arr_temp = implode("",$arr_data_com); $arr_data_dash = explode("--", $arr_temp); for($j=1; $j<sizeof($arr_data_dash); $j+=3) { $ul .="<li>".$arr_data_dash[$j].":".$arr_data_dash[$j+1]."</li>"; } } } } $ul .= '</ul>'; $genhtml = ' <html xmlns="http://www.w3.org/1999/xhtml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxhint" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:mml="http://www.w3.org/1998/math/mathml" xmlns:m="http://schemas.openxmlformats.org/officedocument/2006/math" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingdrawing" xmlns:r="http://schemas.openxmlformats.org/officedocument/2006/relationships"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body id="body1"> <script type="text/php"> echo $ul; </script> </body> </html> '; $dompdf = new \dompdf(); $source = $_server['document_root'].'/pem/source_page.phtml'; file_put_contents($source, $genhtml); $html = file_get_contents($source); $dompdf->load_html($html); $dompdf->set_option('enable_remote', true); $dompdf->set_option('enable_css_float', true); $dompdf->set_option('enable_html5_parser', false); $dompdf->render(); $date = date('y-m-d'); $dompdf->stream("cs_message_".$date.".pdf");
as of v0.6.1 dompdf removed php-preprocessing (e.g. eval
ing <?php ... ?>
).
as of v0.6.x dompdf stopped processing inline script (<script type="text/php"></script>
) default; have enable functionality in configuration. dompdf_enable_php
setting or use $dompdf->set_option('enable_php', true)
.
all being said, you're doing wrong. can't echo
content html document feed dompdf. dompdf not capture content of inline script , feed document. function way access pdf backend during document parsing. need put document prior feeding dompdf.
you not need save file in order load dompdf (unless doing cache page). following should work:
// preceding code intentionally left out $genhtml = ' <html xmlns="http://www.w3.org/1999/xhtml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxhint" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:mml="http://www.w3.org/1998/math/mathml" xmlns:m="http://schemas.openxmlformats.org/officedocument/2006/math" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingdrawing" xmlns:r="http://schemas.openxmlformats.org/officedocument/2006/relationships"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body id="body1"> ' . $ul . ' </body> </html> '; $dompdf = new \dompdf(); $dompdf->load_html($genhtml); $dompdf->set_option('enable_remote', true); $dompdf->set_option('enable_css_float', true); $dompdf->set_option('enable_html5_parser', false); $dompdf->render(); $date = date('y-m-d'); $dompdf->stream("cs_message_".$date.".pdf");
Comments
Post a Comment