mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
🎨 PDF : new helper method to set only font weight and size
This commit is contained in:
@@ -11,6 +11,21 @@ class iTopPDF extends TCPDF
|
||||
{
|
||||
protected $sDocumentTitle;
|
||||
|
||||
/**
|
||||
* Shortcut to set only weight and size
|
||||
*
|
||||
* @param string $style
|
||||
* @param int $size
|
||||
*
|
||||
* @uses \TCPDF::SetFont()
|
||||
* @since 2.7
|
||||
*/
|
||||
public function SetFontParams($style, $size)
|
||||
{
|
||||
$siTopFont = self::GetPdfFont();
|
||||
$this->SetFont($siTopFont, $style, $size);
|
||||
}
|
||||
|
||||
public function SetDocumentTitle($sDocumentTitle)
|
||||
{
|
||||
$this->sDocumentTitle = $sDocumentTitle;
|
||||
@@ -24,7 +39,7 @@ class iTopPDF extends TCPDF
|
||||
{
|
||||
// Title
|
||||
// Set font
|
||||
$this->SetFont(self::GetPdfFont(), 'B', 10);
|
||||
$this->SetFontParams('B', 10);
|
||||
|
||||
$iPageNumberWidth = 25;
|
||||
$aMargins = $this->getMargins();
|
||||
@@ -32,7 +47,7 @@ class iTopPDF extends TCPDF
|
||||
// Display the title (centered)
|
||||
$this->SetXY($aMargins['left'] + $iPageNumberWidth, 0);
|
||||
$this->MultiCell($this->getPageWidth() - $aMargins['left'] - $aMargins['right'] - 2*$iPageNumberWidth, 15, $this->sDocumentTitle, 0, 'C', false, 0 /* $ln */, '', '', true, 0, false, true, 15, 'M' /* $valign */);
|
||||
$this->SetFont(self::GetPdfFont(), '', 10);
|
||||
$this->SetFontParams('', 10);
|
||||
|
||||
// Display the page number (right aligned)
|
||||
// Warning: the 'R'ight alignment does not work when using placeholders like $this->getAliasNumPage() or $this->getAliasNbPages()
|
||||
@@ -138,7 +153,8 @@ EOF
|
||||
|
||||
/**
|
||||
* Get access to the underlying TCPDF object
|
||||
* @return TCPDF
|
||||
*
|
||||
* @return \iTopPDF
|
||||
*/
|
||||
public function get_tcpdf()
|
||||
{
|
||||
|
||||
@@ -162,7 +162,8 @@ class DisplayableNode extends GraphNode
|
||||
}
|
||||
}
|
||||
|
||||
$oPdf->SetFont(iTopPDF::GetPdfFont(), '', 24 * $fScale, '', true);
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', 24 * $fScale, '', true);
|
||||
$width = $oPdf->GetStringWidth($this->GetProperty('label'));
|
||||
$height = $oPdf->GetStringHeight(1000, $this->GetProperty('label'));
|
||||
$oPdf->setAlpha(0.6 * $Alpha);
|
||||
@@ -547,7 +548,8 @@ class DisplayableRedundancyNode extends DisplayableNode
|
||||
$oPdf->Circle($this->x*$fScale, $this->y*$fScale, 16*$fScale, 0, 360, 'DF');
|
||||
|
||||
$oPdf->SetTextColor(255, 255, 255);
|
||||
$oPdf->SetFont(iTopPDF::GetPdfFont(), '', 28 * $fScale, '', true);
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', 28 * $fScale, '', true);
|
||||
$sLabel = (string)$this->GetProperty('label');
|
||||
$width = $oPdf->GetStringWidth($sLabel, iTopPDF::GetPdfFont(), 'B', 24 * $fScale);
|
||||
$height = $oPdf->GetStringHeight(1000, $sLabel);
|
||||
@@ -794,7 +796,8 @@ class DisplayableGroupNode extends DisplayableNode
|
||||
$oPdf->Image($sIconPath, ($this->x - 17)*$fScale, ($this->y - 17)*$fScale, 16*$fScale, 16*$fScale);
|
||||
$oPdf->Image($sIconPath, ($this->x + 1)*$fScale, ($this->y - 17)*$fScale, 16*$fScale, 16*$fScale);
|
||||
$oPdf->Image($sIconPath, ($this->x -8)*$fScale, ($this->y +1)*$fScale, 16*$fScale, 16*$fScale);
|
||||
$oPdf->SetFont(iTopPDF::GetPdfFont(), '', 24 * $fScale, '', true);
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', 24 * $fScale, '', true);
|
||||
$width = $oPdf->GetStringWidth($this->GetProperty('label'));
|
||||
$oPdf->SetTextColor(0, 0, 0);
|
||||
$oPdf->Text($this->x*$fScale - $width/2, ($this->y + 25)*$fScale, $this->GetProperty('label'));
|
||||
@@ -1295,7 +1298,8 @@ class DisplayableGraph extends SimpleGraph
|
||||
$aIcons = array();
|
||||
$aContexts = array();
|
||||
$aContextIcons = array();
|
||||
$oPdf->SetFont(iTopPDF::GetPdfFont(), '', $fFontSize, '', true);
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', $fFontSize, '', true);
|
||||
foreach($oIterator as $sId => $oNode)
|
||||
{
|
||||
if ($sClass = $oNode->GetObjectClass())
|
||||
|
||||
@@ -180,7 +180,7 @@ EOF
|
||||
require_once(APPROOT.'application/pdfpage.class.inc.php');
|
||||
$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(iTopPDF::GetPdfFont(), '', 8, '', true);
|
||||
$oPDF->SetFontParams('', 8);
|
||||
|
||||
$oPage->add(file_get_contents($this->aStatusInfo['tmp_file']));
|
||||
$oPage->add($sData);
|
||||
|
||||
@@ -2063,7 +2063,7 @@ EOF
|
||||
}
|
||||
|
||||
$oPage->get_tcpdf()->AddPage();
|
||||
$oPage->get_tcpdf()->SetFont(iTopPDF::GetPdfFont(), '', 10, '', true); // Reset the font size to its default
|
||||
$oPage->get_tcpdf()->SetFontParams('', 10); // Reset the font size to its default
|
||||
$oPage->add('<div class="page_header"><h1>'.Dict::S('UI:RelationshipList').'</h1></div>');
|
||||
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
|
||||
foreach($aResults as $sListClass => $aObjects)
|
||||
|
||||
Reference in New Issue
Block a user