protected function initPDF()
 {
   
   $this->context =  sfContext::getInstance(); //$this->getContext();
   
   if (sfConfig::get('sf_logging_enabled'))
   {
     $this->context->getLogger()->info('{sfTCPDFView} initPDF');
   }
   //the used values should go into config
   $pdf = new sfTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
   $pdf->SetFont("FreeSerif", "", 12);
   return $pdf;
 }
Example #2
0
 public function Footer()
 {
     parent::Footer();
     $this->SetY($this->y + 2);
     $this->SetX($this->original_lMargin);
     $this->SetFont(PDF_FONT_NAME_MAIN, 'B');
     $this->MultiCell(100, 4, $this->asso->getName(), 0, 'L', 0, 1);
     $this->SetFont(PDF_FONT_NAME_MAIN, '');
     $this->MultiCell(22, 4, 'Site internet :', 0, 'L', 0, 0);
     $this->SetFont(PDF_FONT_NAME_MAIN, 'I');
     $this->MultiCell(70, 4, 'http://assos.utc.fr/' . $this->asso->getLogin(), 0, 'L', 0, 1);
     $this->SetFont(PDF_FONT_NAME_MAIN, '');
     $this->MultiCell(22, 4, 'Adresse email :', 0, 'L', 0, 0);
     $this->SetFont(PDF_FONT_NAME_MAIN, 'I');
     $this->MultiCell(70, 4, $this->asso->getLogin() . '@assos.utc.fr', 0, 'L', 0);
 }
 /**
  * Full test.
  */
 public function executeTest2()
 {
     $config = sfTCPDFPluginConfigHandler::loadConfig();
     sfTCPDFPluginConfigHandler::includeLangFile($this->getUser()->getCulture());
     $doc_title = "test title";
     $doc_subject = "test description";
     $doc_keywords = "test keywords";
     $htmlcontent = "&lt; € &euro; &#8364; &amp; è &egrave; &copy; &gt;<br /><h1>heading 1</h1><h2>heading 2</h2><h3>heading 3</h3><h4>heading 4</h4><h5>heading 5</h5><h6>heading 6</h6>ordered list:<br /><ol><li><b>bold text</b></li><li><i>italic text</i></li><li><u>underlined text</u></li><li><a href=\"http://www.tecnick.com\">link to http://www.tecnick.com</a></li><li>test break<br />second line<br />third line</li><li><font size=\"+3\">font + 3</font></li><li><small>small text</small></li><li>normal <sub>subscript</sub> <sup>superscript</sup></li></ul><hr />table:<br /><table border=\"1\" cellspacing=\"1\" cellpadding=\"1\"><tr><th>#</th><th>A</th><th>B</th></tr><tr><th>1</th><td bgcolor=\"#cccccc\">A1</td><td>B1</td></tr><tr><th>2</th><td>A2 € &euro; &#8364; &amp; è &egrave; </td><td>B2</td></tr><tr><th>3</th><td>A3</td><td><font color=\"#FF0000\">B3</font></td></tr></table><hr />image:<br /><img src=\"sfTCPDFPlugin/images/logo_example.png\" alt=\"test alt attribute\" width=\"100\" height=\"100\" border=\"0\" />";
     //create new PDF document (document units are set by default to millimeters)
     $pdf = new sfTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(PDF_AUTHOR);
     $pdf->SetTitle($doc_title);
     $pdf->SetSubject($doc_subject);
     $pdf->SetKeywords($doc_keywords);
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set image scale factor
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $pdf->setLanguageArray($l);
     //set language items
     //initialize document
     $pdf->AliasNbPages();
     $pdf->AddPage();
     // set barcode
     $pdf->SetBarcode(date("Y-m-d H:i:s", time()));
     // output some HTML code
     $pdf->writeHTML($htmlcontent, true, 0);
     // output two html columns
     $first_column_width = 80;
     $current_y_position = $pdf->getY();
     $pdf->writeHTMLCell($first_column_width, 0, 0, $current_y_position, "<b>hello</b>", 0, 0, 0);
     $pdf->writeHTMLCell(0, 0, $first_column_width, $current_y_position, "<i>world</i>", 0, 1, 0);
     // output some content
     $pdf->Cell(0, 10, "TEST Bold-Italic Cell", 1, 1, 'C');
     // output some UTF-8 test content
     $pdf->AddPage();
     $pdf->SetFont("FreeSerif", "", 12);
     $utf8text = file_get_contents(K_PATH_CACHE . "utf8test.txt", false);
     // get utf-8 text form file
     $pdf->SetFillColor(230, 240, 255, true);
     $pdf->Write(5, $utf8text, '', 1);
     // remove page header/footer
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     // Two HTML columns test
     $pdf->AddPage();
     $right_column = "<b>right column</b> right column right column right column right column\n    right column right column right column right column right column right column\n    right column right column right column right column right column right column";
     $left_column = "<b>left column</b> left column left column left column left column left\n    column left column left column left column left column left column left column\n    left column left column left column left column left column left column left\n    column";
     $first_column_width = 80;
     $second_column_width = 80;
     $column_space = 20;
     $current_y_position = $pdf->getY();
     $pdf->writeHTMLCell($first_column_width, 0, 0, 0, $left_column, 1, 0, 0);
     $pdf->Cell(0);
     $pdf->writeHTMLCell($second_column_width, 0, $first_column_width + $column_space, $current_y_position, $right_column, 0, 0, 0);
     // add page header/footer
     $pdf->setPrintHeader(true);
     $pdf->setPrintFooter(true);
     $pdf->AddPage();
     // Multicell test
     $pdf->MultiCell(40, 5, "A test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 0);
     $pdf->MultiCell(40, 5, "B test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0);
     $pdf->MultiCell(40, 5, "C test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 0);
     $pdf->MultiCell(40, 5, "D test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 2);
     $pdf->MultiCell(40, 5, "F test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0);
     //Close and output PDF document
     $pdf->Output();
     return sfView::NONE;
 }
Example #4
0
 public function executeResumepdf()
 {
     $c = new Criteria();
     $c->add(ResumePeer::USER_ID, $this->getUser()->getAttribute('userid'));
     $resume = ResumePeer::doSelectOne($c);
     // pdf object
     $pdf = new sfTCPDF();
     // 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);
     // init pdf doc
     //$pdf->AliasNbPages();
     $pdf->AddPage();
     //$pdf->Cell(80, 10, $resume->getContent());
     $pdf->writeHTMLCell(200, 10, PDF_MARGIN_LEFT, PDF_MARGIN_TOP, $resume->getContent());
     // output
     $pdf->Output();
     return sfView::NONE;
 }
 public function encabezado($titulo = null, $entidad = null, $fecha = null)
 {
     $config = sfTCPDFPluginConfigHandler::loadConfig('orange');
     // pdf object
     $pdf = new sfTCPDF();
     $pdf->setPageFormat('LETTER');
     $pdf->SetFontSize(8);
     $pdf->SetTextColor(255, 255, 255, 0);
     $pdf->SetDrawColor(192, 192, 192, 0);
     //$pdf->SetCellPadding(30);
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', 8));
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'Generado por:' . $entidad, 'Reporte de Pago' . "\n" . $fecha);
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', 8));
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->SetFontSize(9.5);
     $pdf->setPageFormat('A4');
     return $pdf;
 }
 public function printEtiquetes($idL)
 {
     $config = sfTCPDFPluginConfigHandler::loadConfig();
     //create new PDF document (document units are set by default to millimeters)
     $pdf = new sfTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
     // set document information
     $pdf->SetCreator('Intranet CCG');
     $pdf->SetAuthor('Intranet CCG');
     $pdf->SetTitle('Llistat de mailing postal');
     $pdf->SetSubject("Llistat correu");
     $pdf->SetFont('helvetica', '', 8);
     $pdf->SetMargins(0, 0, 0, 0);
     $pdf->setPrintHeader(false);
     $pdf->setAutoPageBreak(false);
     //Consultem tots els usuaris de la llista que volem imprimir.
     $fila = 1;
     $columna = 1;
     $pagina = 1;
     $pdf->AddPage();
     $OL = LlistesPeer::retrieveByPK($idL);
     foreach ($OL->getUsuarisllistess() as $UL) {
         $OU = $UL->getUsuaris();
         $text = "<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>" . $OU->getNomComplet() . "</b>";
         $text .= "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $OU->getAdreca();
         $text .= "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $OU->getCodiPostal() . ' - ' . $OU->getPoblacioString();
         if ($fila == 9) {
             $pdf->AddPage();
             $fila = 1;
         }
         if ($columna == 1 && $fila == 1) {
             $pdf->MultiCell(70, 37, $text, 1, 'L', 0, 0, 0, 0, true, 0, true, true, 0);
             $columna++;
         } elseif ($columna == 1 && $fila != 1) {
             $pdf->MultiCell(70, 37, $text, 1, 'L', 0, 0, '', '', true, 0, true, true, 0);
             $columna++;
         } elseif ($columna == 2) {
             $pdf->MultiCell(70, 37, $text, 1, 'L', 0, 0, '', '', true, 0, true, true, 0);
             $columna++;
         } elseif ($columna == 3) {
             $pdf->MultiCell(70, 37, $text, 1, 'L', 0, 1, '', '', true, 0, true, true, 0);
             $columna = 1;
             $fila++;
         }
     }
     $pdf->Output();
     return sfView::NONE;
 }
 public function executeCalidadServicio()
 {
     //Obtener los datos para el reporte
     if ($this->getUser()->getAttribute('esValido') === 'no') {
         $this->redirect('reportes/error');
     } else {
         $datepicker = $this->getUser()->getAttribute('datepicker');
         $datepicker2 = $this->getUser()->getAttribute('datepicker2');
         $date2 = Operaciones::convertirFecha($datepicker2);
         $date = Operaciones::convertirFecha($datepicker);
         $carreras = Doctrine_Core::getTable('carrera')->createQuery('a')->where('a.fecha>=?', $date)->andWhere('a.fecha<=?', $date2)->andWhereNotIn('a.calidad', array(-1, -2))->execute();
         // Configurar el reporte
         $doc_title = "Reporte de Carreras - Radiotaxi \"Benjamín Carrión\" ";
         $doc_subject = "Reporte de Carreras - Radiotaxi \"Benjamín Carrión\"";
         $doc_keywords = "Reporte";
         $config = sfTCPDFPluginConfigHandler::loadConfig();
         sfTCPDFPluginConfigHandler::includeLangFile($this->getUser()->getCulture());
         //crear nuevo documento PDF (unidades del documento se establecen de forma predeterminada en milímetros)
         $pdf = new sfTCPDF("l", PDF_UNIT, PDF_PAGE_FORMAT, true);
         // configurar la información del documento
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor('Cooperativa de taxis "Benjamín Carrión"');
         $pdf->SetTitle('INFORME GENERAL DE CARRERAS REALIZADAS');
         $pdf->SetSubject('Radio-taxi');
         $pdf->SetKeywords('Radio-taxi, PDF, Benjamín Carrión, reporte carreras');
         $pdf->SetHeaderData("", 0, PDF_HEADER_TITLE, PDF_HEADER_STRING);
         //establecer los margenes
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         //establecer saltos de página automático
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
         //establecido factor de escala de imagen
         $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
         $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
         //inicializar el documento
         $pdf->AliasNbPages();
         $pdf->AddPage();
         //diseñar el contenido del reporte
         $htmlcontent = "<h1 style=\"text-align:center;\"> Informe de Calidad de Carreras Realizadas</h1> \n    <p>Carreras realizadas desde {$datepicker} hasta {$datepicker2}.</p> ";
         //Detalle de carreras
         $htmlcontent .= "<h3>Detalle de Carreras</h3>\n            <table style=\"font:normal 76%/150% \"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif;border-collapse:separate;border-spacing:0;border-left:1px solid #686868;    border-right:1px solid #686868;    border-bottom: 1px solid #686868;    color:#000;\">    \n        <thead>\n            <tr bgcolor=\"#ffff73\" style=\"font-weight:bold;line-height:normal;padding:0.25em 0.5em;text-align:left;\">\n                <th style=\"border:1px solid #523A0B;border-width:1px 0; width:6%;text-align: center;\">N° </th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Código</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Unidad</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Fecha</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Hora</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Tiempo</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Atención</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Aproximado<br />Destino</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">Llegada</th>\n                <th style=\"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">Calificación<br />Cliente</th>\n            </tr>\n        </thead>\n        <tbody>";
         foreach ($carreras as $i => $carrera) {
             $htmlcontent .= "<tr ";
             if (fmod($i, 2)) {
                 $htmlcontent .= "bgcolor=\"#fcfca0\"";
             } else {
                 $htmlcontent .= "";
             }
             $htmlcontent .= " style= \"border-color:#EBE5D9;padding:0.25em 0.5em;text-align:left;vertical-align:top;\"> \n                <td  style= \"border:1px solid #523A0B;border-width:1px 0;width:6%;\">" . ($i + 1) . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;\">" . $carrera->getNumCodigo() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;\">" . $carrera->getVehiculo() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;\">" . $carrera->getFecha() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;\">" . substr($carrera->getHora(), 0, 5) . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">" . $carrera->getTiempo() . " min</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;\">" . $carrera->getAtencion() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;text-align: center;\">" . $carrera->getTiempoAproxDest() . " min</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:11%;\">" . $carrera->getLlegada() . "</td>\n                <td style= \"border:1px solid #523A0B;border-width:1px 0;width:10%;text-align: center;\">" . $carrera->getCalidad() . "</td>\n            </tr>";
         }
         $htmlcontent .= "</tbody>\n        </table>";
         $pdf->writeHTML($htmlcontent, true, 0);
         // Cerrar y presentar el documento PDF
         $pdf->Output('Reporte.pdf', 'I');
         // Detener el proceso de Symfony
         throw new sfStopException();
     }
 }
Example #8
0
    public function executePdf()
    {
        //        if(!headers_sent()) {
        //            header('Content-Type: application/force-download');
        //            header('Content-Disposition: attachment; filename="export.pdf"');
        //        }
        $pdf = new sfTCPDF();
        $pdf->AddPage();
        $pdf->SetFont('courier', null, '14');
        $html = <<<EOD
<h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a>!</h1>
<i>This is the first example of TCPDF library.</i>
<p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p>
<p>Please check the source code documentation and other examples for further information.</p>
<p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>
EOD;
        $pdf->writeHTML($html);
        $pdf->Output('example_001.pdf', 'I');
        return ViewActions::VIEW_NONE;
    }
Example #9
0
 public function executeConfirmar(sfWebRequest $request)
 {
     $Factura = FacturaQuery::create()->findOneById($request->getParameter('id'));
     $Detalles = FacturaDetalleQuery::create()->findByFacturaId($request->getParameter('id'));
     if (sizeof($Detalles) == 0) {
         $this->getUser()->setFlash('error', 'No existen productos ingresados en esta factura.');
         $this->redirect('venta/detalle?id=' . $request->getParameter('id'));
     }
     if ($Factura->getActivo()) {
         foreach ($Detalles as $detalle) {
             $fecha = date("d/m/Y");
             $Promocion = PromocionQuery::create()->filterByProductoId($detalle->getProductoId())->where("fecha_inicio <= '{$fecha}' and fecha_fin >= '{$fecha}'")->findOne();
             $descuento = 1;
             if ($Promocion) {
                 $descuento = 1 - $Promocion->getDescuento() / 100;
             }
             $Movimiento = new Movimiento();
             $Movimiento->setTipoMovimiento('-');
             $Movimiento->setClienteId($Factura->getClienteId());
             $Movimiento->setProductoId($detalle->getProductoId());
             $Movimiento->setCantidad($detalle->getCantidad());
             $Movimiento->setProveedorId($detalle->getProveedorId());
             $Movimiento->setPrecio($detalle->getPrecioUnitario() * $descuento);
             $Movimiento->setFecha(date('Y-m-d'));
             $Movimiento->save();
         }
         $BitacoraCambios = new BitacoraCambios();
         $BitacoraCambios->setModelo('Factura');
         $BitacoraCambios->setIp(sfContext::getInstance()->getRequest()->getRemoteAddress());
         $BitacoraCambios->setDescripcion('Creacion de Factura con id: ' . sprintf("%05d", $Factura->getId()));
         $Usuario = UsuarioQuery::create()->findOneById(sfContext::getInstance()->getUser()->getAttribute('usuario', null, 'seguridad'));
         if ($Usuario) {
             $Factura->setCreatedBy($Usuario->getUsuario());
             $BitacoraCambios->setCreatedBy($Usuario->getUsuario());
         }
         $BitacoraCambios->save();
         $Cliente = ClienteQuery::create()->findOneById($Factura->getClienteId());
         if (Factura::obtenerTotal($request->getParameter('id')) >= 200) {
             $Cliente->setPuntos($Cliente->getPuntos() + 10);
             $Cliente->save();
         }
     }
     $Factura->setActivo(false);
     $Factura->save();
     $pdf = new sfTCPDF("P", "mm", "Letter");
     $this->id = $request->getParameter("id");
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('SALUD_INTEGRAL');
     $pdf->SetTitle('Factura');
     $pdf->SetSubject('Factura');
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     $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(0.1);
     $pdf->SetFooterMargin(0.1);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetFont('dejavusans', '', 7);
     $pdf->AddPage();
     $html = '';
     $detalles = FacturaDetalleQuery::create()->findByFacturaId($Factura->getId());
     $html = $this->getPartial('venta/soporteTabla', array("factura" => $Factura, "detalles" => $detalles));
     $pdf->writeHTML($html);
     $pdf->Output('Factura.pdf', 'D');
 }
Example #10
0
 protected function doGeneratePdf(sfContext $context, $chartBuilder, $file)
 {
     // definition of chart builder class
     $this->setChartBuilder($chartBuilder);
     // creation of a context
     $context->getConfiguration()->loadHelpers('Partial');
     $context->getRequest()->setRequestFormat('html');
     $config = sfTCPDFPluginConfigHandler::loadConfig();
     sfTCPDFPluginConfigHandler::includeLangFile($context->getUser()->getCulture());
     $doc_title = $this->getName() . " Report";
     $doc_subject = $this->getName() . " Report generated by Otokou";
     $doc_keywords = "report, otokou";
     //create new PDF document (document units are set by default to millimeters)
     $pdf = new sfTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(PDF_AUTHOR);
     $pdf->SetTitle($doc_title);
     $pdf->SetSubject($doc_subject);
     $pdf->SetKeywords($doc_keywords);
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set image scale factor
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     //initialize document
     $pdf->AliasNbPages();
     // report informations
     $pdf->AddPage();
     $html = get_partial('report/general_info', array('report' => $this));
     $pdf->writeHTML($html, true, false, true, false, '');
     // vehicles overall performances
     $html = '<h1>Vehicles performances</h1>' . '<p>The values presented below are calculated overall the entire life period of the vehicle(s).</p>' . get_partial('report/vehicles_performances', array('vehicles' => $this->getVehicles()));
     $pdf->writeHTML($html, true, false, true, false, '');
     // charts
     $pdf->AddPage();
     $html = '<h1>Costs</h1>';
     $pdf->writeHTML($html, true, false, true, false, '');
     $counter = 0;
     $options = array();
     $attributes = array('absolute' => true);
     $charts = $this->defineCharts($options, $attributes);
     $nc = count($charts);
     foreach ($charts as $c) {
         $counter++;
         //$html = get_partial('report/chart', array('chart' => $c));
         //$pdf->writeHTML($html, true, false, true, false, '');
         $html = '<h2>' . $c['title'] . '</h2><p>' . $c['comment'] . '</p>';
         $pdf->writeHTML($html);
         $c['chart']->generate();
         $pdf->Image($c['chart']->getChartFileSystemPath());
         if ($counter < $nc) {
             $pdf->AddPage();
         }
     }
     // Close and output PDF document
     $pdf->Output($file, 'F');
 }