smarty = Qs_Smarty::getObject(); } /** * @param array $data * @param string $template * @param string $file * @param bool $output * @throws Exception * @return void */ public function render(array $data, $template, $file, $output = false, $type = null) { $view = Qs_View::getInstance(); $view->addHelperPath('App/License/View/Helper/', 'App\License\View\Helper\\'); $this->smarty->assign($data); $this->smarty->assign('view', $view); $html = $this->smarty->fetch($template); if ($type == Entity::TYPE_RECEIPT) { $pdf = new Qs_Pdf_Renderer_TcPdf(['wrapper' => PdfReceipt::class]); } else { $pdf = new Qs_Pdf_Renderer_TcPdf(['wrapper' => Pdf::class]); } $pdf->getRenderer()->setPrintHeader(true); $pdf->getRenderer()->SetMargins(10, 48, 10); $pdf->getRenderer()->AddPage(); $pdf->setHtml($html); if ($output) { $pdf->inline(basename($file)); exit; } $dir = dirname($file); if (!file_exists($dir) && false === mkdir($dir, 0755, true)) { throw new Exception('Can\'t create directory ' . $dir); } $pdf->save($file); } }