/**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * Simplifed version of GetDisplaySet() with less "decoration" around the table (and no paging)
  * that fits better into a printed document (like a PDF)
  * @param PDFPage $oPage
  * @param DBObjectSet $oSet
  * @param hash $aExtraParams
  * @return string The HTML representation of the table
  */
 public static function DisplaySetForPrinting(PDFPage $oPage, DBObjectSet $oSet, $aExtraParams = array())
 {
     $iListId = empty($aExtraParams['currentId']) ? $oPage->GetUniqueId() : $aExtraParams['currentId'];
     $sTableId = isset($aExtraParams['table_id']) ? $aExtraParams['table_id'] : null;
     $bViewLink = true;
     $sSelectMode = 'none';
     $iListId = $sTableId;
     $sClassAlias = $oSet->GetClassAlias();
     $sClassName = $oSet->GetClass();
     $sZListName = 'list';
     $aClassAliases = array($sClassAlias => $sClassName);
     $aList = cmdbAbstractObject::FlattenZList(MetaModel::GetZListItems($sClassName, $sZListName));
     $oDataTable = new PrintableDataTable($iListId, $oSet, $aClassAliases, $sTableId);
     $oSettings = DataTableSettings::GetDataModelSettings($aClassAliases, $bViewLink, array($sClassAlias => $aList));
     $oSettings->iDefaultPageSize = 0;
     $oSettings->aSortOrder = MetaModel::GetOrderByDefault($sClassName);
     return $oDataTable->Display($oPage, $oSettings, false, $sSelectMode, $bViewLink, $aExtraParams);
 }
 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;
 }
Ejemplo n.º 4
0
 if ($sDirection == 'up') {
     $oRelGraph = MetaModel::GetRelatedObjectsUp($sRelation, $aSourceObjects, $iMaxRecursionDepth, true, $aContexts);
 } else {
     $oRelGraph = MetaModel::GetRelatedObjectsDown($sRelation, $aSourceObjects, $iMaxRecursionDepth, true, $aExcludedObjects, $aContexts);
 }
 // Remove excluded classes from the graph
 if (count($aExcludedClasses) > 0) {
     $oIterator = new RelationTypeIterator($oRelGraph, 'Node');
     foreach ($oIterator as $oNode) {
         $oObj = $oNode->GetProperty('object');
         if ($oObj && in_array(get_class($oObj), $aExcludedClasses)) {
             $oRelGraph->FilterNode($oNode);
         }
     }
 }
 $oPage = new PDFPage($sTitle, $sPageFormat, $sPageOrientation);
 $oPage->SetContentDisposition('attachment', $sTitle . '.pdf');
 $oGraph = DisplayableGraph::FromRelationGraph($oRelGraph, $iGroupingThreshold, $sDirection == 'down');
 $oGraph->InitFromGraphviz();
 if ($aPositions != null) {
     $oGraph->UpdatePositions($aPositions);
 }
 $aGroups = array();
 $oIterator = new RelationTypeIterator($oGraph, 'Node');
 foreach ($oIterator as $oNode) {
     if ($oNode instanceof DisplayableGroupNode) {
         $aGroups[$oNode->GetProperty('group_index')] = $oNode->GetObjects();
     }
 }
 // First page is the graph
 $oGraph->RenderAsPDF($oPage, $sComments, $sContextKey);