/** * Merge multiple documents. * * @return Dhl_Intraship_Helper_Pdf $this * @throws Dhl_Intraship_Helper_Pdf_Exception */ public function merge() { // Include required fpdi library. if (!class_exists('FPDF', false)) { require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdf.php'; } if (!class_exists('FPDI', false)) { require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdi.php'; } // Try to merge documents via FPDI. try { // Create new FPDI document $this->_document = new FPDI('P', 'mm', $this->getConfig()->getFormat()); $this->_document->SetAutoPageBreak(false); $page = 1; foreach ($this->_collection as $document) { $pages = $this->_document->setSourceFile($document->getFilePath()); for ($i = 1; $i <= $pages; $i++) { $this->_document->addPage(); $this->_document->useTemplate($this->_document->importPage($i, '/MediaBox')); $page++; } } } catch (Exception $e) { throw new Dhl_Intraship_Helper_Pdf_Exception('pdf merging failed. service temporary not available', $e->getCode()); } return $this; }
function renderPDF($id,$mode) { $pdf = new FPDI(); $db_catalogue_pages = new catalogue_pages; $db_catalogue_pages->get_one_catalogue_pages($id); $db_catalogue_pages->load(); $template_id = $db_catalogue_pages->get_pag_template(); $template = new catalogue_templates; $template->getOne($template_id); $template->load(); $pdf->addPage("Landscape","Letter"); $db_catalogue_objects = new catalogue_objects; $db_catalogue_objects->get_all($id); $pdf->SetFont('Arial','',14); $pdf->Image("pdftemplates/".$template->get_tem_file().".jpg",0,0); while($db_catalogue_objects->load()) { $var = explode("_",$db_catalogue_objects->get_obj_var()); if($var[0] == "image") { if(file_exists($db_catalogue_objects->field->obj_image)) $pdf->Image($db_catalogue_objects->field->obj_image,($db_catalogue_objects->field->obj_posx*0.353),($db_catalogue_objects->field->obj_posy*0.353),"50","50"); } $pdf->SetXY($db_catalogue_objects->field->obj_posx*0.353,($db_catalogue_objects->field->obj_posy*0.35) + 60); $pdf->Write(5,$db_catalogue_objects->field->obj_text); } $db_catalogue_objects->close(); $db_catalogue_pages->close(); //if($mode=="I") $pdf->Output("page_".$id.".pdf", "I"); //else $pdf->Output("pages/page_".$id.".pdf", "F"); $pdf->Output("pages/page_".$id.".pdf", "F"); }
} $docs[] = $doc['name'] . ':::' . $cfile->size; // нужно переделать на хеш файла $fnames[] = $cfile->name; $p = pathinfo($cfile->name); if (strtolower($p['extension']) != 'pdf') { $save = false; break; } ++$count_docs; $tmp_name = '/tmp/' . uniqid() . '.pdf'; file_put_contents($tmp_name, file_get_contents(WDCPREFIX . '/' . $cfile->path . $cfile->name)); $pagecount = $pdf->setSourceFile($tmp_name); $tplidx = $pdf->importPage($pagecount, '/MediaBox'); if (preg_match('/^Счет-фактура/', $doc['name'])) { $pdf->addPage('L'); } else { $pdf->addPage('P'); } $pdf->useTemplate($tplidx, 0, 0); if ($doc['type'] == '20480') { $pagecount = $pdf->setSourceFile($tmp_name); $tplidx = $pdf->importPage($pagecount, '/MediaBox'); $pdf->addPage('P'); $pdf->useTemplate($tplidx, 0, 0); } } } if (!$save) { break; }
/** * This method adds a new page to the PDF. */ public function addPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false, $path = NULL, $reset = FALSE, $numbering = 'main') { // Do not add any new page, if we are writing // in the footer or header. if ($this->InFooter) { return; } $this->mainContentPageNumber++; $this->rowContentPageNumber++; // Prevent a reset without any template if ($reset == TRUE && (empty($path) || !file_exists($path))) { parent::addPage(); $this->setPageFormat($this->defaultFormat, $this->defaultOrientation); return; } $files = $this->defaultPageTemplateFiles; // Reset with new template if ($reset) { $files = array(); } if ($path != NULL) { $files[] = array('path' => $path, 'numbering' => $numbering); } $format = FALSE; foreach ($files as $file) { if (!empty($file['path']) && file_exists($file['path'])) { $path = realpath($file['path']); $numberOfPages = $this->setSourceFile($path); if ($file['numbering'] == 'row') { $index = min($this->rowContentPageNumber, $numberOfPages); } else { $index = min($this->mainContentPageNumber, $numberOfPages); } $page = $this->importPage($index); // ajust the page format (only for the first template) if ($format == FALSE) { $dim = $this->getTemplateSize($index); $format[0] = $dim['w']; $format[1] = $dim['h']; //$this->setPageFormat($format); if ($dim['w'] > $dim['h']) { $orientation = 'L'; } else { $orientation = 'P'; } $this->setPageFormat($format, $orientation); parent::addPage(); } // Apply the template $this->useTemplate($page, 0, 0); } } // if all paths were empty, ensure that at least the page is added if ($format == FALSE) { parent::addPage(); $this->setPageFormat($this->defaultFormat, $this->defaultOrientation); } }
$certificate = "lead"; $name = $user->forename . ' ' . $user->surname; // map FPDF to tFPDF so FPDF_TPL can extend it class FPDF extends tFPDF { protected $_tplIdx; } $pdf = new FPDI(); if ($user->getPrivilege() <= 10) { $source = "docs/certificatelead.pdf"; } else { $source = "docs/certificate.pdf"; } $pagecount = $pdf->setSourceFile($source); $tplidx = $pdf->importPage(1); $pdf->addPage('L'); $pdf->useTemplate($tplidx, 0, 0, 0); $date = date('jS F Y'); $pdf->AddFont('DejaVu', '', 'DejaVuSansCondensed.ttf', true); $pdf->SetFont('DejaVu', '', 30); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(0, 95); $pdf->Cell(297, 15, $name, 0, 0, 'C', 0); $pdf->SetFont('Arial', '', 18); $pdf->SetXY(170, 160); $pdf->Write(0, $date); $attachment = $pdf->output('Certificate.pdf', 'S'); header('Pragma: public'); header('Expires: -1'); header('Content-Transfer-Encoding: binary'); header('Content-Type: application/pdf');
function back_id($results) { $this->load->helper('settings'); //print preview of MR $this->load->library('fpdf'); $this->load->library('fpdi'); // initiate FPDI $pdf = new FPDI('L'); // add a page $pdf->AddPage(); // set the sourcefile $pagecount = $pdf->setSourceFile('pdf-report/id/back-id.pdf'); // import page 1 $tplIdx = $pdf->importPage(1); // use the imported page and place it at point 10,10 with a width of 100 mm $pdf->useTemplate($tplIdx); // now write some text above the imported page $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', '', 7); $n = 1; foreach ($results as $result) { $s = new Personal_m(); $row = $s->get_by_employee_id($result->employee_id); //======================== START Column 1 | Right to Left ============================== if ($n == 11) { //add new page $pdf->addPage(); for ($n = 1; $n <= 1; $n++) { $tplidx = $pdf->ImportPage(1); $pdf->useTemplate($tplIdx); //, 1, 1, 210 } $n = $n - 1; } $bday = $row->birth_date; $address = $row->res_address; $blood_type = '"' . $row->blood_type . '"'; $gsis = $row->gsis; $pagibig = $row->pagibig; $philhealth = $row->philhealth; $tin = $row->tin; $emergency = ''; $contact = $row->cp; //----------------------------- Row 1 ---------------------------------- ///Birthday if ($n == 1) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(247, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(257, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(247, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(247, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(247, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(247, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(247, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(235, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(250, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(250); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 2 ---------------------------------- if ($n == 2) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(189, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(199, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(189, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(189, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(189, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(189, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(189, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(177, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(192, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(192); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 3 ---------------------------------- if ($n == 3) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(131, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(141, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(131, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(131, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(131, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(119, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(134, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(134); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 4 ---------------------------------- if ($n == 4) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(73, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(83, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(3); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(73, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(73, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(73, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(61, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(76, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(76); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 5 ---------------------------------- if ($n == 5) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(15, 23); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(25, 15); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(15, 28.3); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(15, 33); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(15, 38); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(15, 43.5); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(15, 48.5); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(3, 75.5); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(18, 78); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(18); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //======================== END Column 1 | Right to Left ============================== //======================== START Column 2 | Right to Left ============================== //----------------------------- Row 1 ---------------------------------- ///Birthday if ($n == 6) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(247, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(257, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(257); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(247, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(247, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(247, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(247, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //TIN $pdf->SetXY(247, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(235, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(250, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(250); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 2 ---------------------------------- //----------------------------- Row 2 ---------------------------------- if ($n == 7) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(189, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(199, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(199); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(189, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(189, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(189, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(189, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //tin $pdf->SetXY(189, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(177, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(192, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(192); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 3 ---------------------------------- if ($n == 8) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(131, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(141, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(141); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(131, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(131, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(131, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(131, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(119, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(134, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(134); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 4 ---------------------------------- if ($n == 9) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(73, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(83, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(83); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(3); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(73, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(73, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(73, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(73, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(61, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(76, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(76); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //----------------------------- Row 5 ---------------------------------- if ($n == 10) { //Birthday if ($bday != '0000-00-00') { $pdf->SetXY(15, 123.5); $pdf->Cell(50, 0, date('F d, Y', strtotime(date('F d, Y', strtotime($bday)))), '0', 0, 'C', false); } //Address $pdf->SetXY(25, 115); $addr = splitstroverflow(ucwords(strtolower(utf8_decode($address))), 28); $pdf->Cell(30, 0, $addr[0], '0', 0, 'C', false); //display text overflow if ($addr[1]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[1], '0', 0, 'C', false); } if ($addr[2]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[2], '0', 0, 'C', false); } if ($addr[3]) { $pdf->Ln(2.5); $pdf->SetX(25); $pdf->Cell(30, 0, $addr[3], '0', 0, 'C', false); } //Blood Type $pdf->SetXY(15, 128.5); $pdf->Cell(50, 0, strtoupper($blood_type), '0', 0, 'C', false); //GSIS $pdf->SetXY(15, 133.5); $pdf->Cell(50, 0, strtoupper($gsis), '0', 0, 'C', false); //PAGIBIG $pdf->SetXY(15, 138.5); $pdf->Cell(50, 0, strtoupper($pagibig), '0', 0, 'C', false); //PHILHEALTH $pdf->SetXY(15, 144); $pdf->Cell(50, 0, strtoupper($philhealth), '0', 0, 'C', false); //tin $pdf->SetXY(15, 149); $pdf->Cell(50, 0, strtoupper($tin), '0', 0, 'C', false); //in case of emergency $pdf->SetXY(3, 176.3); $pdf->Cell(60, 0, strtoupper($emergency), '0', 0, 'C', false); //CP No. $pdf->SetXY(18, 178.5); $cpno = splitstroverflow($contact, 13); $pdf->Cell(30, 0, $cpno[0], '0', 0, 'C', false); if ($cpno[1]) { $pdf->Ln(3); $pdf->SetX(18); $pdf->Cell(30, 0, $cpno[1], '0', 0, 'C', false); } } //======================== END Column 2 | Right to Left ============================== $n++; } // Output $pdf->Output('pdf-report/back-id.pdf', 'F'); return 'pdf-report/back-id.pdf'; }
$pdf->SetFont('TimesNewRomanPSMT', '', 12); $pdf->SetTextColor(0, 0, 0); $pdf->AddPage('L'); $pdf->SetXY(197, 145); $pdf->SetDrawColor(50, 60, 100); $pdf->MultiCell(65, 6, 'Кому: ' . html_entity_decode($letter['user']) . "\nКуда: " . html_entity_decode($letter['address']), 0, 'L'); $pdf->Output("/tmp/{$sid}-{$n}letters.pdf", 'F'); ++$n; } $pdf = new FPDI(); $pagecount = 1; $n = 1; foreach ($envelopes as $letter) { $pagecount = $pdf->setSourceFile("/tmp/{$sid}-{$n}letters.pdf"); $tplidx = $pdf->importPage($pagecount, '/MediaBox'); $pdf->addPage('L'); $pdf->useTemplate($tplidx, 0, 0); if ($letter['files']) { foreach ($letter['files'] as $file_id) { $cfile = new CFile($file_id); if (preg_match("/\\.pdf\$/", $cfile->name)) { $tmp_name = '/tmp/' . uniqid() . '.pdf'; file_put_contents($tmp_name, file_get_contents(WDCPREFIX . '/' . $cfile->path . $cfile->name)); $pagecount = $pdf->setSourceFile($tmp_name); for ($i = 1; $i <= $pagecount; ++$i) { $tplidx = $pdf->importPage($i); $specs = $pdf->getTemplateSize($tplidx); $pdf->addPage($specs['h'] > $specs['w'] ? 'P' : 'L'); $pdf->useTemplate($tplidx); } }
public static function appendVoidText($path_to_dir,$filename,$page=''){ require_once(Yii::app()->basePath.'/extensions/Fpdf/fpdf.php'); require_once(Yii::app()->basePath.'/extensions/Fpdi/fpdi.php'); $pdf = new FPDI(); $pdf->setSourceFile($path_to_dir.'/'.$filename); $tplIdx = $pdf->importPage(1, '/MediaBox'); $pdf->addPage(); $pdf->useTemplate($tplIdx, true); //die("after set sourse"); try{ $pdf->SetFont('Helvetica','B',20); $pdf->SetTextColor(255,0,0); $pdf->SetXY (10,5); $pdf->SetFontSize(10); $pdf->Write(5,'VOID void VOID void VOID void VOID void VOID void VOID void VOID void VOID void VOID void VOID '); $pdf->Output($path_to_dir.'/'.$filename,'F'); }catch (Exception $e) { $result['error']="Could not render this file"; die('Could not render this file'); } $result['path_to_dir']=$path_to_dir; $result['filename']=$filename; $result['ext']='pdf'; return $result; }
$rep = getRAuftrag($_GET["aid"]); $masch = getAllMaschine($rep["mid"]); $firma = getFirmenStamm($masch["customer_id"]); $hist = getHistory($rep["mid"]); $material = getAllMat($_GET["aid"], $rep["mid"]); if ($material) { foreach ($material as $zeile) { $mat .= $zeile["menge"] . " x " . substr($zeile["description"], 0, 70) . "\n"; } } require "fpdf.php"; require "fpdi.php"; $pdf = new FPDI('P', 'mm', 'A4'); $seiten = $pdf->setSourceFile("vorlage/repauftrag.pdf"); $hdl = $pdf->ImportPage(1); $pdf->addPage(); $pdf->useTemplate($hdl); $pdf->SetFont($repfont, 'B', $repsizeL); $pdf->Text($repname[x], $repname[y], utf8_decode($firma["name"])); $pdf->Text($repstr[x], $repstr[y], utf8_decode($firma["street"])); $pdf->Text($report[x], $report[y], $firma["zipcode"] . " " . utf8_decode($firma["city"])); $pdf->Text($repphone[x], $repphone[y], $firma["phone"]); $pdf->Text($repaid[x], $repaid[y], $_GET["aid"]); $pdf->SetFont($repfont, '', $repsizeN); $pdf->Text($repwvnr[x], $repwvnr[y], $masch['contractnumber']); $pdf->Text($repkdnr[x], $repkdnr[y], $firma["customernumber"]); $pdf->Text($repdate[x], $repdate[y], date("d.m.Y")); $pdf->Text($repmasch[x], $repmasch[y], utf8_decode($masch["description"])); $pdf->Text($repser[x], $repser[y], $masch["serialnumber"]); $pdf->Text($repsort[x], $repsort[y], utf8_decode($masch["standort"])); $pdf->Text($repcnt[x], $repcnt[y], $masch["counter"]);
public function generatesExternalReport($id = -1) { /* * Loading libraries and helpers */ $this->load->library(array('rb', 'fpdf_gen')); $this->load->helper(array('date', 'utility')); /* * The request id is not set */ if ($id == -1) { echo "Parece que não foi especificado qual o id da Solicitação."; exit; } /* * Loading request */ $request = R::findOne('request', 'id=?', array($id)); /* * Request exists */ if ($request == null) { echo 'Parece que a solicitação não existe.'; exit; } /* * Creating PDF */ $pdf = new FPDI(); $pdf->addPage('L'); /* ********************************************************* * BEGIN - HEADER ********************************************************* */ $pdf->image(public_url('img/' . $this->config->item('system_report_logo')), 140, 5); $pdf->ln(14); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 0, utf8_decode($this->config->item('system_name')), 0, 0, 'C'); $pdf->Ln(5); $pdf->SetFont('Courier', '', 9); $pdf->Cell(0, 0, utf8_decode("SOLICITAÇÃO DE INFORMAÇÃO"), 0, 0, 'C'); /* ********************************************************* * END - HEADER ********************************************************* */ $pdf->Ln(10); $pdf->SetFont('Courier', 'B', 9); $pdf->SetDrawColor(217, 217, 217); $pdf->SetFillColor(217, 217, 217); $pdf->Cell(0, 10, utf8_decode(' DADOS DA SOLICITAÇÃO'), 'LRTB', 0, 'L', true); $pdf->Ln(10); $pdf->Cell(24, 10, utf8_decode(' PROTOCOLO: '), 'LTB', 0, 'L', false); $pdf->SetFont('Courier', '', 9); $pdf->Cell(110, 10, utf8_decode($request->protocol), 'TBR', 0, 'L', false); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(32, 10, utf8_decode(' SOLICITADA EM: '), 'TB', 0, 'L', false); $pdf->SetFont('Courier', '', 9); $pdf->Cell(111, 10, utf8_decode(mdate('%d/%m/%Y', strtotime($request->createdAt))), 'TBR', 0, 'L', false); $pdf->Ln(10); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(24, 10, utf8_decode(' SITUAÇÃO: '), 'LB', 0, 'L', false); $pdf->SetFont('Courier', '', 9); $pdf->Cell(253, 10, utf8_decode(status_text($request->status)), 'TBR', 0, 'L', false); $pdf->Ln(10); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 10, utf8_decode(' SOLICITAÇÃO: '), 'LR', 0, 'L', false); $pdf->Ln(8); $pdf->SetFont('Courier', '', 9); $pdf->MultiCell(0, 5, utf8_decode(' ' . $request->request), 'LR', 'L', false); $pdf->Cell(0, 4, '', 'LR', 0, 'L', false); $pdf->Ln(4); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 10, utf8_decode(' TRÂMITAÇÃO'), 'LRTB', 0, 'L', true); $pdf->Ln(10); $pdf->SetFont('Courier', '', 9); $statuses = R::find('status', ' request_id = ? ORDER BY created_at ASC ', array($request->id)); if (!count($statuses)) { $pdf->Cell(0, 10, utf8_decode(' Nenhuma trâmitação ainda'), 'LRB', 0, 'L', false); } else { foreach ($statuses as $s) { $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 10, utf8_decode(' ' . status_text($s->type) . ' [' . date('d/m/Y', strtotime($s->createdAt)) . ']'), 'LR', 0, 'L', false); $pdf->Ln(10); $pdf->SetFont('Courier', '', 9); $pdf->MultiCell(0, 5, utf8_decode(' ' . $s->response), 'LRB', 'L', false); } } $pdf->Ln(10); $pdf->Output(); }
/** * This method adds a new page to the PDF. */ public function addPage($path = NULL, $reset = false, $numbering = 'main') { $this->mainContentPageNumber++; $this->rowContentPageNumber++; // Reset without any template if ((empty($path) || !file_exists($path)) && $reset == true) { parent::addPage(); $this->setPageFormat($this->defaultFormat, $this->defaultOrientation); return; } $files = $this->defaultPageTemplateFiles; // Reset with new template if ($reset) { $files = array(); } if ($path != NULL) { $files[] = array('path' => $path, 'numbering' => $numbering); } $format = false; foreach ($files as $file) { if (!empty($file['path']) && file_exists($file['path'])) { $path = realpath($file['path']); $numberOfPages = $this->setSourceFile($path); if ($file['numbering'] == 'row') { $index = min($this->rowContentPageNumber, $numberOfPages); } else { $index = min($this->mainContentPageNumber, $numberOfPages); } $page = $this->importPage($index); // ajust the page format (only for the first template) if ($format == false) { $dim = $this->getTemplateSize($index); $format[0] = $dim['w']; $format[1] = $dim['h']; //$this->setPageFormat($format); if ($dim['w'] > $dim['h']) { $orientation = 'L'; } else { $orientation = 'P'; } $this->setPageFormat($format, $orientation); parent::addPage(); } // Apply the template $this->useTemplate($page,0,0); } } // if all paths were empty, ensure that at least the page is added if ($format == false) { parent::addPage(); $this->setPageFormat($this->defaultFormat, $this->defaultOrientation); } // When a new page is added, we copy the header / footer data from the prvevious page. // this ensures that we get always the data, independent on a page break // inside a record. if (isset($this->headerFooterData[($this->getPage() - 1)])) { // $this->headerFooterData[$this->getPage()] = $this->headerFooterData[($this->getPage() - 1)]; } }
public function ceaseAndDesistPDFAction(Request $request, $work, $name) { //try { $user = $this->getUser(); $file = $this->getDoctrine()->getRepository('AppBundle:ProtectedFile')->findOneBy(array("registrationNumber" => $work)); $pdf = new \FPDI(); $pdf->SetFont('Helvetica', '', 11); $pdf->addPage('P'); $pdf->SetXY(13, 10); $pdf->Write(8, strip_tags($this->renderView('profile/ceaseAndDesistLetter.html.twig', array('user' => $user, 'name' => $name, 'work' => $file)))); $pdf = $this->createAttachmentPDF($file, $pdf); $response = new Response($pdf->Output('D', 'Cease&Desist Letter.pdf'), Response::HTTP_OK); $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'Cease&Desist Letter.pdf'); return $response; //} catch (\Exception $e) { // return new BinaryFileResponse(null); //} }
/** * resizePdf * * @return void */ public function resizePdf() { try { if (false === class_exists('FPDF', false)) { require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdf.php'; } if (false === class_exists('FPDI', false)) { require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdi.php'; } // Create new FPDI document $document = new FPDI('P', 'mm', $this->getConfig()->getFormat()); $margins = $this->getConfig()->getMargins(); $document->SetAutoPageBreak(false); $pages = $document->setSourceFile($this->getPathToPdf()); for ($i = 1; $i <= $pages; $i++) { $document->addPage(); $document->useTemplate($document->importPage($i, '/MediaBox'), $margins['left'], $margins['top']); } $document->Output($this->getPathToPdf(), 'F'); } catch (Exception $e) { throw new Dhl_Intraship_Helper_Pdf_Exception('pdf resizing failed. service temporary not available. ' . $e->getMessage(), $e->getCode()); } }
public function generateCoupon($coupon_image_url, $user_id, $email_id) { require_once $_SERVER['DOCUMENT_ROOT'] . '/application/libraries/fpdf/fpdf.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/application/libraries/fpdf/fpdi.php'; $pdf = new FPDI(); $pageCount = $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . "/application/libraries/coupon.pdf"); $tplIdx = $pdf->importPage(1, '/MediaBox'); $count = 0; $y = 145.5; $i = 1; $amt = 0; $pdf->addPage(); $pdf->useTemplate($tplIdx, 3, 3, 210, 300); $pdf->SetFont('Arial', '', '9'); $pdf->SetTextColor(0, 0, 0); $pdf->Text(50, 80, 'User ID :'); $pdf->Text(100, 80, $user_id); $pdf->Text(50, 90, 'Email ID :'); $pdf->Text(100, 90, $email_id); $pdf->Image($coupon_image_url, 50, 100); $save_status = 1; if (!$save_status) { $pdf->Output(); } else { $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/images/coupons/' . 'coupon_' . $user_id . '.pdf', 'F'); } }