diff --git a/library/Icinga/File/Pdf.php b/library/Icinga/File/Pdf.php index 4f3f24c90..fd90a0299 100644 --- a/library/Icinga/File/Pdf.php +++ b/library/Icinga/File/Pdf.php @@ -1,5 +1,4 @@ render(); $layout->content = $controller->getResponse(); $html = $layout->render(); - $imgDir = Url::fromPath('img'); $html = preg_replace('~src="' . $imgDir . '/~', 'src="' . Icinga::app()->getBootstrapDirecory() . '/img/', $html); - //echo $html; exit; $this->load_html($html); - - /* - // TODO: We need to find a solution for page footers - $font = Font_Metrics::get_font("helvetica", "bold"); - $canvas = $this->get_canvas(); - $canvas->page_text(555, 750, "{PAGE_NUM}/{PAGE_COUNT}", $font, 10, array(0,0,0)); - $dompdf->page_script(' - // $pdf is the variable containing a reference to the canvas object provided by dompdf - $pdf->line(10,730,800,730,array(0,0,0),1); - '); - */ $this->render(); $this->stream( sprintf( @@ -93,127 +59,4 @@ class Pdf extends DOMPDF ) ); } - - /** - * @param $body - * @param $css - */ -/* public function renderPage($body, $css) - { - $html = - '
' - . '' - . '' - . $body - . '' - . ''; - if ($this->paginateTable === true) { - $doc = new DOMDocument(); - @$doc->loadHTML($html); - $this->paginateHtmlTables($doc); - $html = $doc->saveHtml(); - } - $this->load_html($html); - $this->render(); - }*/ - - /** - * Split up tables into multiple elements that each contain $rowsPerPage of all original rows - * - * NOTE: This is a workaround to fix the buggy page-break on table-rows in dompdf. - * - * @param DOMDocument $doc The html document containing the tables. - * - * @return array All paginated tables from the document. - */ -/* private function paginateHtmlTables(DOMDocument $doc) - { - $xpath = new DOMXPath($doc); - $tables = $xpath->query('.//table'); - $paginated = array(); - $j = 0; - - foreach ($tables as $table) { - $containerType = null; - $rows = $xpath->query('.//tr', $table); - $rowCnt = $rows->length; - $tableCnt = (Integer)ceil($rowCnt / $this->rowsPerPage); - $paginated[$j] = array(); - if ($rowCnt <= $this->rowsPerPage) { - continue; - } - // remove all rows from the original parent - foreach ($rows as $row) { - if (!isset($containerType)) { - $containerType = $row->parentNode->nodeName; - } - $row->parentNode->removeChild($row); - } - - // clone table for each additional page and fetch the row containers - $containers = array(); - $pages = array(); - - if ($this->tableInitialPageBreak) { - $this->pageBreak($doc, $table); - } - for ($i = 0; $i < $tableCnt; $i++) { - // clone table - $currentPage = $table->cloneNode(true); - $pages[$i] = $currentPage; - $table->parentNode->insertBefore($currentPage, $table); - - // put it in current paginated table - $paginated[$j] = $currentPage; - - // insert page-break - if ($i < $tableCnt - 1) { - $this->pageBreak($doc, $table); - } - - // fetch row container - $container = $xpath->query('.//' . $containerType, $currentPage)->item(0); - $containers[$i] = $container; - } - - $i = 0; - foreach ($rows as $row) { - $p = (Integer)floor($i / $this->rowsPerPage); - $containers[$p]->appendChild($row); - $i++; - } - - // remove original table - $table->parentNode->removeChild($table); - $j++; - } - return $paginated; - } - - private function pageBreak($doc, $before) - { - $div = $doc->createElement('div'); - $div->setAttribute('style', 'page-break-before: always;'); - $before->parentNode->insertBefore($div, $before); - } -*/ - /** - * Prepare the given css for rendering with DOMPDF, by removing or hiding all incompatible - * styles - * - * @param $css The css-string - * - * @return string A css-string that is ready to use for DOMPDF - */ - -// public static function prepareCss($css) -// { -// $css = preg_replace('/\*:\s*before\s*,\s*/', '', $css); -// $css = preg_replace('/\*\s*:\s*after\s*\{[^\}]*\}/', '', $css); -// return $css; -// } - -} -// @codeCoverageIgnoreEnd +} \ No newline at end of file