/** * @param Layout $default_layout */ public function __construct(Layout $default_layout) { $this->pdf = new \TCPDF('P', 'pt', 'A4', true, 'UTF-8'); $this->pdf->SetTitle($default_layout->getReportTitle()); $this->pdf->SetCreator('Thinreports Generator'); $this->pdf->SetAutoPageBreak(false); $this->pdf->SetMargins(0, 0, 0, true); $this->pdf->SetCellPadding(0); $this->pdf->SetCellMargins(0, 0, 0, 0); $this->pdf->SetPrintHeader(false); $this->pdf->SetPrintFooter(false); $this->default_layout = $default_layout; $this->default_page_format = $this->buildPageFormat($default_layout); }
/** * @param Layout|null $default_layout */ public function __construct(Layout $default_layout = null) { $this->pdf = new \TCPDF('P', 'pt', 'A4', true, 'UTF-8'); $this->pdf->SetCreator('Thinreports Generator'); $this->pdf->SetAutoPageBreak(false); $this->pdf->SetMargins(0, 0, 0, true); $this->pdf->SetCellPadding(0); $this->pdf->SetCellMargins(0, 0, 0, 0); $this->pdf->SetPrintHeader(false); $this->pdf->SetPrintFooter(false); if ($default_layout !== null) { $this->pdf->SetTitle($default_layout->getReportTitle()); $this->registerPageFormat($default_layout); } $this->initDrawer(); }
/** * Tests for: * Layout::getLastVersion * Layout::getReportTitle * Layout::getPagePaperType * Layout::isUserPaperType * Layout::isPortraitPage * Layout::getPageSize * Layout::getSVG */ function test_getters_for_Layout_configuration() { $regular_paper_type_format = array('version' => '0.8.2', 'config' => array('title' => 'Report Title', 'page' => array('paper-type' => 'A4', 'orientation' => 'landscape')), 'svg' => '<svg></svg>'); $layout = new Layout($regular_paper_type_format, array()); $this->assertEquals('0.8.2', $layout->getLastVersion()); $this->assertEquals('Report Title', $layout->getReportTitle()); $this->assertEquals('A4', $layout->getPagePaperType()); $this->assertFalse($layout->isUserPaperType()); $this->assertFalse($layout->isPortraitPage()); $this->assertNull($layout->getPageSize()); $this->assertEquals('<svg></svg>', $layout->getSVG()); $user_paper_type_format = array('version' => '0.8.2', 'config' => array('title' => 'Report Title', 'page' => array('paper-type' => 'user', 'orientation' => 'landscape', 'width' => 100.9, 'height' => 999.9)), 'svg' => '<svg></svg>'); $layout = new Layout($user_paper_type_format, array()); $this->assertEquals('user', $layout->getPagePaperType()); $this->assertTrue($layout->isUserPaperType()); $this->assertEquals(array(100.9, 999.9), $layout->getPageSize()); }