<?php require_once 'gridPdfGenerator.php'; require_once 'tcpdf/tcpdf.php'; require_once 'gridPdfWrapper.php'; $debug = false; $error_handler = set_error_handler("PDFErrorHandler"); if (get_magic_quotes_gpc()) { $xmlString = stripslashes($_POST['grid_xml']); } else { $xmlString = $_POST['grid_xml']; } $xmlString = urldecode($xmlString); if ($debug == true) { error_log($xmlString, 3, 'debug_' . date("Y_m_d__H_i_s") . '.xml'); } $xml = simplexml_load_string($xmlString); $pdf = new gridPdfGenerator(); $pdf->printGrid($xml); function PDFErrorHandler($errno, $errstr, $errfile, $errline) { global $xmlString; if ($errno < 1024) { error_log($xmlString, 3, 'error_report_' . date("Y_m_d__H_i_s") . '.xml'); echo $errfile . " at " . $errline . " : " . $errstr; exit(1); } }
public function pdfAction() { require_once ROOT_DIR . '/vendor/My/grid-pdf-php/gridPdfGenerator.php'; require_once ROOT_DIR . '/vendor/My/grid-pdf-php/tcpdf/tcpdf.php'; require_once ROOT_DIR . '/vendor/My/grid-pdf-php/gridPdfWrapper.php'; if ($this->sSessionNameSpace != '') { $container = new \Zend\Session\Container($this->sSessionNameSpace); $this->getReadTable()->createWhere($container); if ($container->offsetExists('orderby')) { $this->getReadTable()->createOrder($container->offsetGet('orderby'), $container->offsetGet('direction')); } } $paginator = $this->getReadTable()->fetchAllPaginator(); $iCount = (int) $this->params()->fromQuery('count', 20); $iStart = (int) $this->params()->fromQuery('posStart', 0); $iPage = round($iStart / $iCount, 0, PHP_ROUND_HALF_UP) + 1; $paginator->setCurrentPageNumber($iPage); $iCount = $paginator->getTotalItemCount(); $paginator->setItemCountPerPage($iCount); $adapter = $paginator->getAdapter(); $results = $adapter->getItems($iStart, $iCount); $aHead = $this->prepareHeadGrid(); $sFooter = implode(',', $this->getReadTable()->getColumnViewList()); $oMyGrid = new Grid($results->toArray(), 'id', '', array_merge($aHead, array('footer' => $this->getReadTable()->getColumnViewList()))); $oMyGrid->setPagingGrid($iStart, $paginator->getTotalItemCount()); $xml = $oMyGrid->createXml(); ob_clean(); $pdf = new \gridPdfGenerator(); $xmlPDF = simplexml_load_string($xml); $pdf->printGrid($xmlPDF); exit; }