public function testSetGetPdfOptions() { $model = new PdfModel(); $options = new PdfOptions(); $model->setPdfOptions($options); $this->assertInstanceOf('UthandoDomPdf\\Options\\PdfOptions', $model->getPdfOptions()); }
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); $config = isset($config['uthando_dompdf']['pdf_options']) ? $config['uthando_dompdf']['pdf_options'] : []; $options = new PdfOptions($config); $model = new PdfModel(); $model->setPdfOptions($options); return $model; }
/** * Renders values as a PDF * * @param string|ModelInterface|PdfModel $nameOrModel * @param null|array|\ArrayAccess Values to use during rendering * @return string The script output. */ public function render($nameOrModel, $values = null) { $pdfOptions = $nameOrModel->getPdfOptions(); $paperSize = explode(',', $pdfOptions->getPaperSize()); $paperOrientation = $pdfOptions->getPaperOrientation(); $basePath = $pdfOptions->getBasePath(); $paperSize = count($paperSize) === 1 ? $paperSize[0] : $paperSize; $pdf = $this->getEngine(); $pdf->setPaper($paperSize, $paperOrientation); $pdf->setBasePath($basePath); $html = $this->getHtmlRenderer()->render($nameOrModel, $values); $pdf->loadHtml($html); $pdf->render(); $pdf = $this->processHeader($pdf, $pdfOptions); $pdf = $this->processFooter($pdf, $pdfOptions); return $pdf->output(); }