PMCORE-3540 BE: Generate a output document using the header, footer and pagination defined
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\PDF\TCPDFHeaderFooter;
|
||||
|
||||
class OutputDocument extends BaseOutputDocument
|
||||
{
|
||||
@@ -879,7 +880,7 @@ class OutputDocument extends BaseOutputDocument
|
||||
$content = str_replace("margin-left", "text-indent", $content);
|
||||
|
||||
// Instance the TCPDF library
|
||||
$pdf = new TCPDF($orientation, PDF_UNIT, $media, true, 'UTF-8', false);
|
||||
$pdf = new TCPDFHeaderFooter($orientation, PDF_UNIT, $media, true, 'UTF-8', false);
|
||||
|
||||
// Set document information
|
||||
$pdf->SetCreator(PDF_CREATOR);
|
||||
@@ -896,8 +897,10 @@ class OutputDocument extends BaseOutputDocument
|
||||
$margins["bottom"] = ($margins["bottom"] >= 0) ? $margins["bottom"] : PDF_MARGIN_BOTTOM;
|
||||
|
||||
// Set margins configuration
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
$headerOptions = $this->setHeaderOptions($pdf);
|
||||
$footerOptions = $this->setFooterOptions($pdf);
|
||||
$pdf->setPrintHeader($headerOptions);
|
||||
$pdf->setPrintFooter($footerOptions);
|
||||
$pdf->SetLeftMargin($margins['left']);
|
||||
$pdf->SetTopMargin($margins['top']);
|
||||
$pdf->SetRightMargin($margins['right']);
|
||||
@@ -1362,4 +1365,68 @@ class OutputDocument extends BaseOutputDocument
|
||||
// Save the CSS file
|
||||
file_put_contents(K_PATH_FONTS . 'fonts.css', $css);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and build if header options exist.
|
||||
* @param TCPDFHeaderFooter $pdf
|
||||
* @return bool
|
||||
*/
|
||||
private function setHeaderOptions(TCPDFHeaderFooter $pdf): bool
|
||||
{
|
||||
if (empty($this->out_doc_header)) {
|
||||
return false;
|
||||
}
|
||||
$header = json_decode($this->out_doc_header);
|
||||
|
||||
$struct = $pdf->getHeaderStruct();
|
||||
|
||||
$struct->setLogo($header->logo);
|
||||
$struct->setLogoWidth($header->logoWidth);
|
||||
$struct->setLogoPositionX($header->logoPositionX);
|
||||
$struct->setLogoPositionY($header->logoPositionY);
|
||||
|
||||
$struct->setTitle($header->title);
|
||||
$struct->setTitleFontSize($header->titleFontSize);
|
||||
$struct->setTitleFontPositionX($header->titleFontPositionX);
|
||||
$struct->setTitleFontPositionY($header->titleFontPositionY);
|
||||
|
||||
$struct->setPageNumber($header->pageNumber);
|
||||
$struct->setPageNumberTitle($header->pageNumberTitle);
|
||||
$struct->setPageNumberTotal($header->pageNumberTotal);
|
||||
$struct->setPageNumberPositionX($header->pageNumberPositionX);
|
||||
$struct->setPageNumberPositionY($header->pageNumberPositionY);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and build if footer options exist.
|
||||
* @param TCPDFHeaderFooter $pdf
|
||||
* @return bool
|
||||
*/
|
||||
private function setFooterOptions(TCPDFHeaderFooter $pdf): bool
|
||||
{
|
||||
if (empty($this->out_doc_footer)) {
|
||||
return false;
|
||||
}
|
||||
$footer = json_decode($this->out_doc_footer);
|
||||
|
||||
$struct = $pdf->getFooterStruct();
|
||||
|
||||
$struct->setLogo($footer->logo);
|
||||
$struct->setLogoWidth($footer->logoWidth);
|
||||
$struct->setLogoPositionX($footer->logoPositionX);
|
||||
$struct->setLogoPositionY($footer->logoPositionY);
|
||||
|
||||
$struct->setTitle($footer->title);
|
||||
$struct->setTitleFontSize($footer->titleFontSize);
|
||||
$struct->setTitleFontPositionX($footer->titleFontPositionX);
|
||||
$struct->setTitleFontPositionY($footer->titleFontPositionY);
|
||||
|
||||
$struct->setPageNumber($footer->pageNumber);
|
||||
$struct->setPageNumberTitle($footer->pageNumberTitle);
|
||||
$struct->setPageNumberTotal($footer->pageNumberTotal);
|
||||
$struct->setPageNumberPositionX($footer->pageNumberPositionX);
|
||||
$struct->setPageNumberPositionY($footer->pageNumberPositionY);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
336
workflow/engine/src/ProcessMaker/PDF/BasicStruct.php
Normal file
336
workflow/engine/src/ProcessMaker/PDF/BasicStruct.php
Normal file
@@ -0,0 +1,336 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
/**
|
||||
* Struct for header and footer configuration.
|
||||
*/
|
||||
trait BasicStruct
|
||||
{
|
||||
/**
|
||||
* Path to image file.
|
||||
* @var string
|
||||
*/
|
||||
private $logo = '';
|
||||
|
||||
/**
|
||||
* Width to image file, the height is calculated automatically proportional
|
||||
* to the original dimensions.
|
||||
* @var float
|
||||
*/
|
||||
private $logoWidth = 0;
|
||||
|
||||
/**
|
||||
* Position of the image with respect to the ordinate X since left margin.
|
||||
* @var float
|
||||
*/
|
||||
private $logoPositionX = 0;
|
||||
|
||||
/**
|
||||
* Position of the image with respect to the ordinate Y since top margin.
|
||||
* @var float
|
||||
*/
|
||||
private $logoPositionY = 0;
|
||||
|
||||
/**
|
||||
* Title of the page.
|
||||
* @var string
|
||||
*/
|
||||
private $title = '';
|
||||
|
||||
/**
|
||||
* Font size of the title.
|
||||
* @var float
|
||||
*/
|
||||
private $titleFontSize = 0;
|
||||
|
||||
/**
|
||||
* Position of the title with respect to the ordinate X since left margin.
|
||||
* @var float
|
||||
*/
|
||||
private $titleFontPositionX = 0;
|
||||
|
||||
/**
|
||||
* Position of the title with respect to the ordinate Y since top margin.
|
||||
* @var float
|
||||
*/
|
||||
private $titleFontPositionY = 0;
|
||||
|
||||
/**
|
||||
* Indicates if the page number is displayed.
|
||||
* @var bool
|
||||
*/
|
||||
private $pageNumber = false;
|
||||
|
||||
/**
|
||||
* Alternative text to indicate the numbered page.
|
||||
* @var string
|
||||
*/
|
||||
private $pageNumberTitle = '';
|
||||
|
||||
/**
|
||||
* Indicates if the pages total is displayed.
|
||||
* @var bool
|
||||
*/
|
||||
private $pageNumberTotal = false;
|
||||
|
||||
/**
|
||||
* Position of the page number with respect to the ordinate X since left margin.
|
||||
* @var float
|
||||
*/
|
||||
private $pageNumberPositionX = 0;
|
||||
|
||||
/**
|
||||
* Position of the page number with respect to the ordinate Y since bottom margin.
|
||||
* @var float
|
||||
*/
|
||||
private $pageNumberPositionY = 0;
|
||||
|
||||
/**
|
||||
* Get logo property.
|
||||
* @return string
|
||||
*/
|
||||
public function getLogo(): string
|
||||
{
|
||||
return $this->logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logoWidth property.
|
||||
* @return float
|
||||
*/
|
||||
public function getLogoWidth(): float
|
||||
{
|
||||
return $this->logoWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logoPositionX property.
|
||||
* @return float
|
||||
*/
|
||||
public function getLogoPositionX(): float
|
||||
{
|
||||
return $this->logoPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logoPositionY property.
|
||||
* @return float
|
||||
*/
|
||||
public function getLogoPositionY(): float
|
||||
{
|
||||
return $this->logoPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title property.
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get titleFontSize property.
|
||||
* @return float
|
||||
*/
|
||||
public function getTitleFontSize(): float
|
||||
{
|
||||
return $this->titleFontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get titleFontPositionX property.
|
||||
* @return float
|
||||
*/
|
||||
public function getTitleFontPositionX(): float
|
||||
{
|
||||
return $this->titleFontPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get titleFontPositionY property.
|
||||
* @return float
|
||||
*/
|
||||
public function getTitleFontPositionY(): float
|
||||
{
|
||||
return $this->titleFontPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumber property.
|
||||
* @return bool
|
||||
*/
|
||||
public function getPageNumber(): bool
|
||||
{
|
||||
return $this->pageNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberTitle property.
|
||||
* @return string
|
||||
*/
|
||||
public function getPageNumberTitle(): string
|
||||
{
|
||||
return $this->pageNumberTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberTotal property.
|
||||
* @return bool
|
||||
*/
|
||||
public function getPageNumberTotal(): bool
|
||||
{
|
||||
return $this->pageNumberTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberPositionX property.
|
||||
* @return float
|
||||
*/
|
||||
public function getPageNumberPositionX(): float
|
||||
{
|
||||
return $this->pageNumberPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageNumberPositionY property.
|
||||
* @return float
|
||||
*/
|
||||
public function getPageNumberPositionY(): float
|
||||
{
|
||||
return $this->pageNumberPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property title.
|
||||
* @param string $title
|
||||
* @return void
|
||||
*/
|
||||
public function setTitle(string $title): void
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property titleFontSize.
|
||||
* @param float $titleFontSize
|
||||
* @return void
|
||||
*/
|
||||
public function setTitleFontSize(float $titleFontSize): void
|
||||
{
|
||||
$this->titleFontSize = $titleFontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property titleFontPositionX.
|
||||
* @param float $titleFontPositionX
|
||||
* @return void
|
||||
*/
|
||||
public function setTitleFontPositionX(float $titleFontPositionX): void
|
||||
{
|
||||
$this->titleFontPositionX = $titleFontPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property titleFontPositionY.
|
||||
* @param float $titleFontPositionY
|
||||
* @return void
|
||||
*/
|
||||
public function setTitleFontPositionY(float $titleFontPositionY): void
|
||||
{
|
||||
$this->titleFontPositionY = $titleFontPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logo.
|
||||
* @param string $logo
|
||||
* @return void
|
||||
*/
|
||||
public function setLogo(string $logo): void
|
||||
{
|
||||
$this->logo = $logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logoWidth.
|
||||
* @param float $logoWidth
|
||||
* @return void
|
||||
*/
|
||||
public function setLogoWidth(float $logoWidth): void
|
||||
{
|
||||
$this->logoWidth = $logoWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logoPositionX.
|
||||
* @param float $logoPositionX
|
||||
* @return void
|
||||
*/
|
||||
public function setLogoPositionX(float $logoPositionX): void
|
||||
{
|
||||
$this->logoPositionX = $logoPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property logoPositionY.
|
||||
* @param float $logoPositionY
|
||||
* @return void
|
||||
*/
|
||||
public function setLogoPositionY(float $logoPositionY): void
|
||||
{
|
||||
$this->logoPositionY = $logoPositionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumber.
|
||||
* @param bool $pageNumber
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumber(bool $pageNumber): void
|
||||
{
|
||||
$this->pageNumber = $pageNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberTitle.
|
||||
* @param string $pageNumberTitle
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberTitle(string $pageNumberTitle): void
|
||||
{
|
||||
$this->pageNumberTitle = $pageNumberTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberTotal.
|
||||
* @param bool $pageNumberTotal
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberTotal(bool $pageNumberTotal): void
|
||||
{
|
||||
$this->pageNumberTotal = $pageNumberTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberPositionX.
|
||||
* @param float $pageNumberPositionX
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberPositionX(float $pageNumberPositionX): void
|
||||
{
|
||||
$this->pageNumberPositionX = $pageNumberPositionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set property pageNumberPositionY.
|
||||
* @param float $pageNumberPositionY
|
||||
* @return void
|
||||
*/
|
||||
public function setPageNumberPositionY(float $pageNumberPositionY): void
|
||||
{
|
||||
$this->pageNumberPositionY = $pageNumberPositionY;
|
||||
}
|
||||
|
||||
}
|
||||
11
workflow/engine/src/ProcessMaker/PDF/FooterStruct.php
Normal file
11
workflow/engine/src/ProcessMaker/PDF/FooterStruct.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
class FooterStruct
|
||||
{
|
||||
/**
|
||||
* Using basic struct for footer properties.
|
||||
*/
|
||||
use BasicStruct;
|
||||
}
|
||||
11
workflow/engine/src/ProcessMaker/PDF/HeaderStruct.php
Normal file
11
workflow/engine/src/ProcessMaker/PDF/HeaderStruct.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
class HeaderStruct
|
||||
{
|
||||
/**
|
||||
* Using basic struct for header properties.
|
||||
*/
|
||||
use BasicStruct;
|
||||
}
|
||||
242
workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooter.php
Normal file
242
workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooter.php
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\PDF;
|
||||
|
||||
use TCPDF;
|
||||
|
||||
class TCPDFHeaderFooter extends TCPDF
|
||||
{
|
||||
/**
|
||||
* Property for configure header element.
|
||||
* @var HeaderStruct
|
||||
*/
|
||||
private $headerStruct;
|
||||
|
||||
/**
|
||||
* Property for configure footer element.
|
||||
* @var FooterStruct
|
||||
*/
|
||||
private $footerStruct;
|
||||
|
||||
/**
|
||||
* Save the original margins configured in the page.
|
||||
* @var array
|
||||
*/
|
||||
private $originalMargins;
|
||||
|
||||
/**
|
||||
* Constructor of the class.
|
||||
* @param string $orientation
|
||||
* @param string $unit
|
||||
* @param string $format
|
||||
* @param bool $unicode
|
||||
* @param string $encoding
|
||||
* @param bool $diskcache
|
||||
* @param bool $pdfa
|
||||
*/
|
||||
public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4', $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa = false)
|
||||
{
|
||||
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);
|
||||
$this->headerStruct = new HeaderStruct();
|
||||
$this->footerStruct = new FooterStruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor of the class.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
parent::__destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an object that contains the properties of the header.
|
||||
* @return HeaderStruct
|
||||
*/
|
||||
public function getHeaderStruct(): HeaderStruct
|
||||
{
|
||||
return $this->headerStruct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an object that contains the properties of the footer.
|
||||
* @return FooterStruct
|
||||
*/
|
||||
public function getFooterStruct(): FooterStruct
|
||||
{
|
||||
return $this->footerStruct;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to render the page header.
|
||||
* This method has been overwritten.
|
||||
*/
|
||||
public function Header()
|
||||
{
|
||||
$heights = [];
|
||||
$struct = $this->getHeaderStruct();
|
||||
|
||||
if (empty($this->originalMargins)) {
|
||||
$this->originalMargins = $this->getMargins();
|
||||
}
|
||||
$margins = $this->originalMargins;
|
||||
|
||||
$this->buildHeaderLogo($struct, $margins, $heights);
|
||||
$this->buildHeaderTitle($struct, $margins, $heights);
|
||||
$this->buildHeaderPageNumber($struct, $margins, $heights);
|
||||
|
||||
//page adjust
|
||||
$newHeight = max($heights);
|
||||
$this->SetTopMargin($newHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build header logo.
|
||||
* @param HeaderStruct $struct
|
||||
* @param array $margins
|
||||
* @param array $heights
|
||||
* @return void
|
||||
*/
|
||||
private function buildHeaderLogo(HeaderStruct $struct, array $margins, array &$heights): void
|
||||
{
|
||||
$path = $struct->getLogo();
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
$pathinfo = pathinfo($path);
|
||||
$imageSize = getimagesize($path);
|
||||
$extension = $pathinfo['extension'];
|
||||
$x = $struct->getLogoPositionX() + $margins['left'];
|
||||
$y = $struct->getLogoPositionY() + $margins['top'];
|
||||
$width = $struct->getLogoWidth();
|
||||
$this->Image($path, $x, $y, $width, 0, $extension, '', '', false, 300, '', false, false, 0, false, false, false);
|
||||
$newImageHeight = ($width * $imageSize[0] / $imageSize[1]);
|
||||
$heights[] = $margins['top'] + $newImageHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build header title.
|
||||
* @param HeaderStruct $struct
|
||||
* @param array $margins
|
||||
* @param array $heights
|
||||
* @return void
|
||||
*/
|
||||
private function buildHeaderTitle(HeaderStruct $struct, array $margins, array &$heights): void
|
||||
{
|
||||
$string = $struct->getTitle();
|
||||
$x = $struct->getTitleFontPositionX() + $margins['left'];
|
||||
$y = $struct->getTitleFontPositionY() + $margins['top'];
|
||||
$fontSize = $struct->getTitleFontSize();
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'B', $fontSize);
|
||||
$this->MultiCell(0, 0, $string, 0, 'L', false, 1, '', '', true, 0, false, true, 0, 'T', false);
|
||||
$heights[] = $margins['top'] + ($this->getCellHeight($fontSize, false)) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build header page number.
|
||||
* @param HeaderStruct $struct
|
||||
* @param array $margins
|
||||
* @param array $heights
|
||||
* @return void
|
||||
*/
|
||||
private function buildHeaderPageNumber(HeaderStruct $struct, array $margins, array &$heights): void
|
||||
{
|
||||
if ($struct->getPageNumber() === true) {
|
||||
$pageString = empty($struct->getPageNumberTitle()) ? 'Page ' : $struct->getPageNumberTitle() . ' ';
|
||||
$pageNumberTotal = $struct->getPageNumberTotal() === true ? ' / ' . $this->getAliasNbPages() : '';
|
||||
$string = $pageString . $this->getAliasNumPage() . $pageNumberTotal;
|
||||
$x = $struct->getPageNumberPositionX() + $margins['left'];
|
||||
$y = $struct->getPageNumberPositionY() + $margins['top'];
|
||||
$fontSize = 8;
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'I', $fontSize);
|
||||
$this->Cell(0, 0, $string, 0, 0, '', false, '', 0, false, 'T', 'M');
|
||||
$heights[] = $margins['top'] + ($this->getCellHeight($fontSize, false)) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to render the page footer.
|
||||
* This method has been overwritten.
|
||||
*/
|
||||
public function Footer()
|
||||
{
|
||||
$struct = $this->getFooterStruct();
|
||||
|
||||
if (empty($this->originalMargins)) {
|
||||
$this->originalMargins = $this->getMargins();
|
||||
}
|
||||
$margins = $this->originalMargins;
|
||||
|
||||
//page adjust
|
||||
$this->SetY(-1 * ($margins['bottom']));
|
||||
$currentY = $this->GetY();
|
||||
|
||||
$this->buildFooterLogo($margins, $currentY, $struct);
|
||||
$this->buildFooterTitle($margins, $currentY, $struct);
|
||||
$this->buildFooterPageNumber($margins, $currentY, $struct);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build footer logo.
|
||||
* @param array $margins
|
||||
* @param float $currentY
|
||||
* @param HeaderStruct $struct
|
||||
* @return void
|
||||
*/
|
||||
private function buildFooterLogo(array $margins, float $currentY, FooterStruct $struct): void
|
||||
{
|
||||
$path = $struct->getLogo();
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
$pathinfo = pathinfo($path);
|
||||
$extension = $pathinfo['extension'];
|
||||
$x = $struct->getLogoPositionX() + $margins['left'];
|
||||
$y = $struct->getLogoPositionY() + $currentY;
|
||||
$width = $struct->getLogoWidth();
|
||||
$this->Image($path, $x, $y, $width, 0, $extension, '', '', false, 300, '', false, false, 0, false, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build footer title.
|
||||
* @param array $margins
|
||||
* @param float $currentY
|
||||
* @param HeaderStruct $struct
|
||||
* @return void
|
||||
*/
|
||||
private function buildFooterTitle(array $margins, float $currentY, FooterStruct $struct): void
|
||||
{
|
||||
$string = $struct->getTitle();
|
||||
$x = $struct->getTitleFontPositionX() + $margins['left'];
|
||||
$y = $struct->getTitleFontPositionY() + $currentY;
|
||||
$fontSize = $struct->getTitleFontSize();
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'B', $fontSize);
|
||||
$this->MultiCell(0, 0, $string, 0, 'L', false, 1, '', '', true, 0, false, true, 0, 'T', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build footer page number.
|
||||
* @param array $margins
|
||||
* @param float $currentY
|
||||
* @param HeaderStruct $struct
|
||||
* @return void
|
||||
*/
|
||||
private function buildFooterPageNumber(array $margins, float $currentY, FooterStruct $struct): void
|
||||
{
|
||||
if ($struct->getPageNumber() === true) {
|
||||
$pageString = empty($struct->getPageNumberTitle()) ? 'Page ' : $struct->getPageNumberTitle() . ' ';
|
||||
$pageNumberTotal = $struct->getPageNumberTotal() === true ? ' / ' . $this->getAliasNbPages() : '';
|
||||
$string = $pageString . $this->getAliasNumPage() . $pageNumberTotal;
|
||||
$x = $struct->getPageNumberPositionX() + $margins['left'];
|
||||
$y = $struct->getPageNumberPositionY() + $currentY;
|
||||
$fontSize = 8;
|
||||
$this->SetXY($x, $y);
|
||||
$this->SetFont('helvetica', 'I', $fontSize);
|
||||
$this->Cell(0, 0, $string, 0, 0, '', false, '', 0, false, 'T', 'M');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user