/** * Renders the graph in a PDF document: centered in the current page * @param PDFPage $oPage The PDFPage representing the PDF document to draw into * @param string $sComments An optional comment to display next to the graph (HTML entities will be escaped, \n replaced by <br/>) * @param string $sContextKey The key to fetch the queries in the configuration. Example: itop-tickets/relation_context/UserRequest/impacts/down * @param float $xMin Left coordinate of the bounding box to display the graph * @param float $xMax Right coordinate of the bounding box to display the graph * @param float $yMin Top coordinate of the bounding box to display the graph * @param float $yMax Bottom coordinate of the bounding box to display the graph */ function RenderAsPDF(PDFPage $oPage, $sComments = '', $sContextKey, $xMin = -1, $xMax = -1, $yMin = -1, $yMax = -1) { $aContextDefs = static::GetContextDefinitions($sContextKey, false); // No need to develop the parameters $oPdf = $oPage->get_tcpdf(); $aBB = $this->GetBoundingBox(); $this->Translate(-$aBB['xmin'], -$aBB['ymin']); $aMargins = $oPdf->getMargins(); if ($xMin == -1) { $xMin = $aMargins['left']; } if ($xMax == -1) { $xMax = $oPdf->getPageWidth() - $aMargins['right']; } if ($yMin == -1) { $yMin = $aMargins['top']; } if ($yMax == -1) { $yMax = $oPdf->getPageHeight() - $aMargins['bottom']; } $fBreakMargin = $oPdf->getBreakMargin(); $oPdf->SetAutoPageBreak(false); $aRemainingArea = $this->RenderKey($oPdf, $sComments, $xMin, $yMin, $xMax, $yMax, $aContextDefs); $xMin = $aRemainingArea['xmin']; $xMax = $aRemainingArea['xmax']; $yMin = $aRemainingArea['ymin']; $yMax = $aRemainingArea['ymax']; //$oPdf->Rect($xMin, $yMin, $xMax - $xMin, $yMax - $yMin, 'D', array(), array(225, 50, 50)); $fPageW = $xMax - $xMin; $fPageH = $yMax - $yMin; $w = $aBB['xmax'] - $aBB['xmin']; $h = $aBB['ymax'] - $aBB['ymin'] + 10; // Extra space for the labels which may appear "below" the icons $fScale = min($fPageW / $w, $fPageH / $h); $dx = ($fPageW - $fScale * $w) / 2; $dy = ($fPageH - $fScale * $h) / 2; $this->Translate(($xMin + $dx) / $fScale, ($yMin + $dy) / $fScale); $oIterator = new RelationTypeIterator($this, 'Edge'); $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop'); foreach ($oIterator as $sId => $oEdge) { set_time_limit($iLoopTimeLimit); $oEdge->RenderAsPDF($oPdf, $this, $fScale, $aContextDefs); } $oIterator = new RelationTypeIterator($this, 'Node'); foreach ($oIterator as $sId => $oNode) { set_time_limit($iLoopTimeLimit); $oNode->RenderAsPDF($oPdf, $this, $fScale, $aContextDefs); } $oIterator = new RelationTypeIterator($this, 'Node'); $oPdf->SetAutoPageBreak(true, $fBreakMargin); $oPdf->SetAlpha(1); }
public function GetFooter() { $sData = parent::GetFooter(); $oPage = new PDFPage(Dict::Format('Core:BulkExportOf_Class', MetaModel::GetName($this->oSearch->GetClass())), $this->aStatusInfo['page_size'], $this->aStatusInfo['page_orientation']); $oPDF = $oPage->get_tcpdf(); $oPDF->SetFont('dejavusans', '', 8, '', true); $oPage->add(file_get_contents($this->aStatusInfo['tmp_file'])); $oPage->add($sData); $sPDF = $oPage->get_pdf(); return $sPDF; }