oPdf = new iTopPDF($sPageOrientation, 'mm', $sPageFormat, true, self::PAGES_CHARSET, false); // set document information $this->oPdf->SetCreator(PDF_CREATOR); $this->oPdf->SetAuthor('iTop'); $this->oPdf->SetTitle($s_title); $this->oPdf->SetDocumentTitle($s_title); $this->oPdf->setFontSubsetting(true); // dejavusans is a UTF-8 Unicode font. Standard PDF fonts like helvetica or times new roman are NOT UTF-8 $this->oPdf->SetFontParams('', 10, '', true); // set auto page breaks $this->oPdf->SetAutoPageBreak(true, 15); // 15 mm break margin at the bottom $this->oPdf->SetTopMargin(15); // Add a page, we're ready to start $this->oPdf->AddPage(); $this->SetContentDisposition('inline', $s_title.'.pdf'); $this->SetDefaultStyle(); $oKpi->ComputeStats(get_class($this).' creation', 'PDFPage'); } /** * Sets a default style (suitable for printing) to be included each time $this->oPdf->writeHTML() is called */ protected function SetDefaultStyle() { $this->add_style( <<flush(); return $this->oPdf; } /** * Writes the currently buffered HTML content into the PDF. This can be useful: * - to sync the flow in case you want to access the underlying TCPDF object for some specific/graphic output * - to process the HTML by smaller chunks instead of processing the whole page at once for performance reasons */ public function flush() { $sHtml = ''; if (count($this->a_styles) > 0) { $sHtml .= "\n"; } if (strlen($this->s_content) > 0) { $sHtml .= $this->s_content; $this->s_content = ''; } $sHtml .= BlockRenderer::RenderBlockTemplates($this->oContentLayout); $this->oPdf->writeHTML($sHtml); // The style(s) must be supplied each time we call writeHtml } /** * Whether or not the page is a PDF page * * @return boolean */ public function is_pdf() { return true; } /** * Generates the PDF document and returns the PDF content as a string * * @return string * @see WebPage::output() */ public function output() { $this->add_header('Content-type: application/x-pdf'); if (!empty($this->sContentDisposition)) { $this->add_header('Content-Disposition: '.$this->sContentDisposition.'; filename="'.$this->sContentFileName.'"'); } foreach ($this->a_headers as $s_header) { header($s_header); } $this->flush(); echo $this->oPdf->Output($this->s_title.'.pdf', 'S'); } public function get_pdf() { $this->flush(); return $this->oPdf->Output($this->s_title.'.pdf', 'S'); } }