sterntours/trunk/src/AppBundle/Pdf.php
adametz ad4dff526c booking form responsive
git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3463 f459cee4-fb09-11de-96c3-f9c5f16c3c76
2018-09-07 11:52:08 +00:00

53 lines
No EOL
1.6 KiB
PHP

<?php
namespace AppBundle;
use TCPDF;
class Pdf extends TCPDF
{
private $webDir;
private $assetManager;
function __construct($rootDir, $assetManager)
{
parent::__construct('P', 'mm', 'A4', true, 'UTF-8', false, false);//($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);//('P', 'mm', 'A4', true, 'UTF-8', false, false);
$this->webDir = realpath($rootDir . '/../web');
$this->assetManager = $assetManager;
}
private function getFileName($file)
{
$assetPath = $this->assetManager->get($file)->getTargetPath();
$fileNameParts = explode('/', $assetPath);
$lastPartIndex = count($fileNameParts) - 1;
$fileName = $fileNameParts[$lastPartIndex];
return $fileName;
}
public function Header()
{
$backgroundDir = $this->webDir.'/bundles/app/images/header-bg.png';
$logoDir = $this->webDir.'/assetic/'.$this->getFileName('headerLogo');
$this->Image($backgroundDir, 0, 0, 210, 0, '', '', '', false, 300, 'C');
$this->Image($logoDir, 0, 15, 90, 0, '', '', '', false, 300, 'C');
}
public function Footer()
{
$footerDir = $this->webDir.'/assetic/footerPDF.svg';
$this->ImageSVG($footerDir, 0, 228, 210, '');
$this->SetY(-58);
$this->SetX(-30);
$this->SetFont('helvetica', '', 10);
$this->Cell(0, 14, 'Seite '.$this->getAliasNumPage().' von '.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
/* End of file Pdf.php */
/* Location: ./application/libraries/Pdf.php */