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'); }