function Output($type) { $type = strtolower($type); //Initialize PDF object so all subclasses can access it. //Loop through all objects and combine the output from each into a single document. if ($type == 'pdf') { if (!class_exists('tcpdf')) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->tcpdf_dir . DIRECTORY_SEPARATOR . 'tcpdf.php'; } if (!class_exists('fpdi')) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->fpdi_dir . DIRECTORY_SEPARATOR . 'fpdi.php'; } $pdf = new FPDI('P', 'pt'); $pdf->setMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(FALSE); $pdf->setFontSubsetting(FALSE); foreach ($this->objs as $obj) { $obj->setPDFObject($pdf); $obj->Output($type); } return $pdf->Output('', 'S'); } elseif ($type == 'efile') { foreach ($this->objs as $obj) { return $obj->Output($type); } } elseif ($type == 'xml') { //Since multiple XML sections may need to be joined together, //We must pass the XML object between each form and build the entire XML object completely //then output it all at once at the end. $xml = NULL; $xml_schema = NULL; foreach ($this->objs as $obj) { if (is_object($xml)) { $obj->setXMLObject($xml); } $obj->Output($type); if (isset($obj->xml_schema)) { $xml_schema = $obj->getClassDirectory() . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR . $obj->xml_schema; } if ($xml == NULL and is_object($obj->getXMLObject())) { $xml = $obj->getXMLObject(); } } if (is_object($xml)) { $output = $xml->asXML(); $xml_validation_retval = $this->validateXML($output, $xml_schema); if ($xml_validation_retval !== TRUE) { Debug::text('XML Schema is invalid! Malformed XML!', __FILE__, __LINE__, __METHOD__, 10); //$output = FALSE; $output = $xml_validation_retval; } } else { Debug::text('No XML object!', __FILE__, __LINE__, __METHOD__, 10); $output = FALSE; } return $output; } }
public function executeBatchPrintBadge(sfWebRequest $request) { $ids = $request->getParameter('ids'); // initiate FPDI $pdf = new FPDI('P', 'pt'); // set the sourcefile $pdf->setSourceFile(sfConfig::get('sf_upload_dir') . '/badges/ID_new.pdf'); foreach ($ids as $id) { $this->employee = EmployeePeer::retrieveByPk($id); // import page 1 $tplIdx = $pdf->importPage(1); // add a new page based on size of the badge $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage('P', array($s['w'], $s['h'])); $pdf->useTemplate($tplIdx); $pdf->setMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(false); if ($this->employee->getPicture()) { $pdf->Image(sfConfig::get('sf_upload_dir') . '/' . sfConfig::get('app_employee_images_dir') . '/' . $this->employee->getPicture(), 29.5, 25.5, 60.3, 74.3); } else { $pdf->Image(sfConfig::get('sf_upload_dir') . '/badges/picture_missing.jpg', 29.5, 25.5, 60.3, 74.3); } // now write some text above the imported page $pdf->SetFont('freesans', 'B', 12); $pdf->SetTextColor(82, 78, 134); $pdf->SetXY(22, 110); $pdf->Cell(0, 12, $this->employee->getFullName()); $pdf->Ln(); $pdf->SetX(22); $pdf->SetFont('freesans', 'BI', 10); $pdf->Cell(0, 14, $this->employee->getJob()); $pdf->SetDisplayMode('real'); } return $pdf->Output('newpdf.pdf', 'D'); }
function Output($type) { $type = strtolower($type); //Initialize PDF object so all subclasses can access it. //Loop through all objects and combine the output from each into a single document. if ($type == 'pdf') { if (!class_exists('tcpdf')) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->tcpdf_dir . DIRECTORY_SEPARATOR . 'tcpdf.php'; } if (!class_exists('fpdi')) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->fpdi_dir . DIRECTORY_SEPARATOR . 'fpdi.php'; } $pdf = new FPDI('P', 'pt'); $pdf->setMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(FALSE); foreach ($this->objs as $obj) { $obj->setPDFObject($pdf); $obj->Output($type); } return $pdf->Output('', 'S'); } }