public function executePdf(sfWebRequest $request) { $this->certificate = Doctrine_Core::getTable('Certificate')->findOneByToken(array($request->getParameter('token'))); $this->forward404Unless($this->certificate); //$config = sfTCPDFPluginConfigHandler::loadConfig(); // pdf object $pdf = new myPDF(); // settings $pdf->SetFont("FreeSerif", "", 12); /* $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); */ //$pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // init pdf doc //$pdf->AliasNbPages(); $pdf->AddPage('L', array(132,66)); $pdf->Cell(80, 10, "Certificate číslo: ". $this->certificate->token); $this->setLayout(false); // output $response = $this->getContext()->getResponse(); $response->clearHttpHeaders(); $response->setHttpHeader('Pragma', 'public'); $response->setHttpHeader('Cache-Control', ''); $response->setHttpHeader('Content-Type', 'application/pdf'); $response->setHttpHeader('Content-Disposition', 'attachment; filename="invoice.pdf"'); $response->setContent($pdf->Output()); return sfView::NONE; // return $pdf->Output(); // Stop symfony process // throw new sfStopException(); } } include '/var/www/oleg/slevy/plugins/sfTCPDFPlugin/lib/tcpdf/tcpdf.php'; // Extend the TCPDF class to create custom Header and Footer //class MYPDF extends sfTCPDF { class MYPDF extends TCPDF { //Page header public function Header() { // full background image // store current auto-page-break status $bMargin = $this->getBreakMargin(); $auto_page_break = $this->AutoPageBreak; $this->SetAutoPageBreak(false, 0); $img_file = sfConfig::get('sf_web_dir') . '/images/bg_kupon.jpg'; $this->Image($img_file, 0, 0, 132, 66, '', '', '', false, 300, '', false, false, 0); // restore auto-page-break status $this->SetAutoPageBreak($auto_page_break, $bMargin); } }
среда, 6 апреля 2011 г.
symfony render PDF
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий