/** * 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 generate_mitgliedsbescheinigung($titleAndName, $strasse, $plz, $ort, $land, $jahr, $vorstand, $datum) { // initiate FPDI $pdf = new FPDI(); // add a page $pdf->AddPage(); // set the source file $pdf->setSourceFile(HOME_DIRECTORY . 'alumpiHP_libraries/Mitgliedsbestaetigung_blank.pdf'); // import page 1 $tplIdx = $pdf->importPage(1); // use the imported page and place it at position 0,0 with a width of 210 mm (full page) $pdf->useTemplate($tplIdx, 0, 0, 210); // add the font DejaVu $pdf->AddFont('DejaVuSans', '', 'DejaVuSans.ttf', true); $pdf->AddFont('DejaVuSans-Bold', '', 'DejaVuSans-Bold.ttf', true); // text settings $pdf->SetTextColor(0, 0, 0); // add address of the member $addressString = $titleAndName . "\n"; $addressString .= $strasse . "\n"; $addressString .= $plz . " " . $ort . "\n"; $addressString .= $land; $pdf->SetFont('DejaVuSans'); $pdf->SetFontSize(12); $pdf->SetXY(20, 23); $pdf->Multicell(80, 6, $addressString); //add heading $headingString = "Mitgliedsbescheinigung " . $jahr; $pdf->SetFont('DejaVuSans-Bold'); $pdf->SetFontSize(16); $pdf->SetXY(20, 80); $pdf->Multicell(170, 6, $headingString); // add main text $textString = "Hiermit wird bestätigt, dass " . $titleAndName . " im Kalenderjahr " . $jahr; $textString .= " ordentliches Mitglied des Absolventen- und Förderverein MPI Uni Bayreuth e.V. (aluMPI) ist.\n"; $textString .= "\n"; $pdf->SetFont('DejaVuSans'); $pdf->SetFontSize(12); $pdf->SetXY(20, 100); $pdf->Multicell(170, 6, $textString); // add signature text $signatureString = "Absolventen- und Förderverein MPI Uni Bayreuth e.V.\n"; $signatureString .= "1. Vorstand: " . $vorstand . "\n"; $pdf->SetXY(20, 140); $pdf->Multicell(170, 6, $signatureString); // add signature $pdf->Image(HOME_DIRECTORY . 'alumpiHP_libraries/unterschrift_krinninger.png', 20, 155, 50); // add place and date $dateString = "Bayreuth, " . $datum; $pdf->SetXY(20, 180); $pdf->Multicell(170, 6, $dateString); ob_clean(); $pdf->Output(); }
function generate_philosophy_certificate($confirmation, $form, $entry, $ajax) { // print_r( $entry ); die; if ($entry['gquiz_is_pass']) { $upload_dir = wp_upload_dir(); // initiate FPDI $pdf = new FPDI(); // set the sourcefile $pdf->setSourceFile(get_template_directory() . '/library/certificate.pdf'); // import page 1 $tplIdx = $pdf->importPage(1); // get the width and height of the template $specs = $pdf->getTemplateSize($tplIdx); // add a page $pdf->AddPage("L", array($specs['w'], $specs['h'])); // use the imported page as the template $pdf->useTemplate($tplIdx, 0, 0); // now write some text above the imported page $pdf->SetY(101); $pdf->SetFont("dejavuserifbi", 'I', 35); $pdf->SetTextColor(0, 54, 99); $text = $entry['2.3'] . " " . $entry['2.6']; $pdf->MultiCell(260, 40, $text, 0, 'C'); // now write some text above the imported page $pdf->SetY(165); $pdf->SetFont("dejavuserifbi", 'I', 22); $pdf->SetTextColor(0, 54, 99); $text = date('F j, Y'); $pdf->MultiCell(260, 22, $text, 0, 'C'); // save the pdf out to file $pdf->Output($upload_dir['basedir'] . '/certificates/' . $entry['id'] . '.pdf', 'F'); } return array('redirect' => '/philosophy-results/?id=' . $entry['id']); }
public function createPDF(FPDI $fpdi, $filename) { $fpdi->setSourceFile(__DIR__ . '/A.pdf'); $template = $fpdi->importPage(1); $size = $fpdi->getTemplateSize($template); $fpdi->AddPage('P', array($size['w'], $size['h'])); $fpdi->useTemplate($template); $template = $fpdi->importPage(1); $fpdi->AddPage('P', array($size['w'], $size['h'])); $fpdi->useTemplate($template); file_put_contents($filename, $fpdi->Output('', 'S')); }
public function testMerge() { $fpdi = new FPDI(); $fpdi->setSourceFile(__DIR__ . '/A.pdf'); $template = $fpdi->importPage(1); $size = $fpdi->getTemplateSize($template); $fpdi->AddPage('P', array($size['w'], $size['h'])); $fpdi->useTemplate($template); $template = $fpdi->importPage(1); $fpdi->AddPage('P', array($size['w'], $size['h'])); $fpdi->useTemplate($template); file_put_contents(__DIR__ . '/AA.pdf', $fpdi->Output('', 'S')); }
public function runProcessStep($dokument) { $file = $dokument->getLatestRevision()->getFile(); $extension = array_pop(explode(".", $file->getExportFilename())); #$this->ziphandler->addFile($file->getAbsoluteFilename(), $file->getExportFilename()); // Print Metainfo for PDFs if (strtolower($extension) == "pdf") { try { $fpdf = new FPDI(); $pagecount = $fpdf->setSourceFile($file->getAbsoluteFilename()); $fpdf->SetMargins(0, 0, 0); $fpdf->SetFont('Courier', '', 8); $fpdf->SetTextColor(0, 0, 0); $documentSize = null; for ($i = 0; $i < $pagecount; $i++) { $string = $dokument->getLatestRevision()->getIdentifier() . " (Seite " . ($i + 1) . " von " . $pagecount . ", Revision " . $dokument->getLatestRevision()->getRevisionID() . ")"; $fpdf->AddPage(); $tpl = $fpdf->importPage($i + 1); $size = $fpdf->getTemplateSize($tpl); // First Page defines documentSize if ($documentSize === null) { $documentSize = $size; } // Center Template on Document $fpdf->useTemplate($tpl, intval(($documentSize["w"] - $size["w"]) / 2), intval(($documentSize["h"] - $size["h"]) / 2), 0, 0, true); $fpdf->Text(intval($documentSize["w"]) - 10 - $fpdf->GetStringWidth($string), 5, $string); } $this->ziphandler->addFromString($dokument->getLatestRevision()->getIdentifier() . "." . $extension, $fpdf->Output("", "S")); } catch (Exception $e) { $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension); } } else { $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension); } }
/** * Merges your provided PDFs and outputs to specified location. * @param $outputmode * @param $outputname * @return PDF */ public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf') { if (!isset($this->_files) || !is_array($this->_files)) { throw new exception("No PDFs to merge."); } $fpdi = new FPDI(); //merger operations foreach ($this->_files as $file) { $filename = $file[0]; $filepages = $file[1]; $count = $fpdi->setSourceFile($filename); //add the pages if ($filepages == 'all') { for ($i = 1; $i <= $count; $i++) { $template = $fpdi->importPage($i); $size = $fpdi->getTemplateSize($template); $orientation = $size['h'] > $size['w'] ? 'P' : 'L'; $fpdi->AddPage($orientation, array($size['w'], $size['h'])); $fpdi->useTemplate($template); } } else { foreach ($filepages as $page) { if (!($template = $fpdi->importPage($page))) { throw new exception("Could not load page '{$page}' in PDF '{$filename}'. Check that the page exists."); } $size = $fpdi->getTemplateSize($template); $orientation = $size['h'] > $size['w'] ? 'P' : 'L'; $fpdi->AddPage($orientation, array($size['w'], $size['h'])); $fpdi->useTemplate($template); } } } //output operations $mode = $this->_switchmode($outputmode); if ($mode == 'S') { return $fpdi->Output($outputpath, 'S'); } else { if ($fpdi->Output($outputpath, $mode) == '') { return true; } else { throw new exception("Error outputting PDF to '{$outputmode}'."); return false; } } }
public function listAction() { $receipt = new \FPDI(); // PDFの余白(上左右)を設定 $receipt->SetMargins(0, 0, 0); // ヘッダーの出力を無効化 $receipt->setPrintHeader(false); // フッターの出力を無効化 $receipt->setPrintFooter(false); // フォントを登録 $fontPathRegular = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-regular.ttf'; // $regularFont = $receipt->addTTFfont($fontPathRegular, '', '', 32); $font = new TCPDF_FONTS(); $regularFont = $font->addTTFfont($fontPathRegular); $fontPathBold = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-bold.ttf'; // $boldFont = $receipt->addTTFfont($fontPathBold, '', '', 32); $font = new TCPDF_FONTS(); $boldFont = $font->addTTFfont($fontPathBold); // ページを追加 $receipt->AddPage(); // テンプレートを読み込み // $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/receipt.pdf'); // $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/template.pdf'); // $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/w01_1.pdf'); $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/senijiten.pdf'); // 読み込んだPDFの1ページ目のインデックスを取得 $tplIdx = $receipt->importPage(1); // 読み込んだPDFの1ページ目をテンプレートとして使用 $receipt->useTemplate($tplIdx, null, null, null, null, true); // 書き込む文字列のフォントを指定 $receipt->SetFont($regularFont, '', 11); // 書き込む文字列の文字色を指定 $receipt->SetTextColor(0, 0, 255); // X : 42mm / Y : 108mm の位置に $receipt->SetXY(59, 248); // 文字列を書き込む $receipt->Write(0, isset($_POST['name']) ? $_POST['name'] . 'さん' : '名無しさん'); /* $response = new Response( // Output関数の第一引数にはファイル名、第二引数には出力タイプを指定する // 今回は文字列で返してほしいので、ファイル名はnull、出力タイプは S = String を選択する $receipt->Output(null, 'S'), 200, array('content-type' => 'application/pdf') ); // レスポンスヘッダーにContent-Dispositionをセットし、ファイル名をreceipt.pdfに指定 $response->headers->set('Content-Disposition', 'attachment; filename="receipt.pdf"'); return $response; */ // $receipt-> $receipt->output('newpdf.pdf', 'I'); }
function split_pdf($filename, $end_directory = false, $num = 1) { require_once 'fpdf/fpdf.php'; require_once 'fpdi/fpdi.php'; $end_directory = $end_directory ? $end_directory . date("d-m-Y__H-i-s") . "/" : './'; $new_path = preg_replace('/[\\/]+/', '/', $end_directory . '/' . substr($filename, 0, strrpos($filename, '/'))); if (!is_dir($new_path)) { // Will make directories under end directory that don't exist // Provided that end directory exists and has the right permissions mkdir($new_path, 0777, true); } $pdf = new FPDI(); $pagecount = $pdf->setSourceFile($filename); // How many pages? $j = 0; // Split each page into a new PDF $new_pdf = new FPDI(); for ($i = 1; $i <= $pagecount; $i++) { $new_pdf->AddPage(); $new_pdf->setSourceFile($filename); $new_pdf->useTemplate($new_pdf->importPage($i)); if ($i != 1 && $i % $num == 0 || $num == 1) { try { $new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . $i . ".pdf"; $new_pdf->Output($new_filename, "F"); $url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/"; echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } unset($new_pdf); $new_pdf = new FPDI(); $j = 0; } $j++; } if ($j != 0) { try { $new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . ($i - 1) . ".pdf"; $new_pdf->Output($new_filename, "F"); $url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/"; echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } }
function carl_merge_pdfs_fpdi($pdffiles, $titles = array(), $metadata = array(), $metadata_encoding = 'UTF-8') { // FPDI throws some notices that break the PDF $old_error = error_reporting(E_ERROR | E_WARNING | E_PARSE); include_once INCLUDE_PATH . 'pdf/tcpdf/tcpdf.php'; include_once INCLUDE_PATH . 'pdf/fpdi/fpdi.php'; if (gettype($pdffiles) != 'array') { trigger_error('$pdffiles must be an array'); return false; } if (!(class_exists('TCPDF') && class_exists('FPDI'))) { trigger_error('You must have TCPDF/FPDI installed in order to run carl_merge_pdfs()'); return false; } if (empty($pdffiles)) { return NULL; } $fpdi = new FPDI(); foreach ($pdffiles as $pdffile) { if (file_exists($pdffile)) { $count = $fpdi->setSourceFile($pdffile); for ($i = 1; $i <= $count; $i++) { $template = $fpdi->importPage($i); $size = $fpdi->getTemplateSize($template); $fpdi->AddPage('P', array($size['w'], $size['h'])); $fpdi->useTemplate($template, null, null, null, null, true); if ($i == 1) { if (isset($titles[$pdffile])) { $bookmark = html_entity_decode($titles[$pdffile]); } else { $bookmark = $pdffile; } $fpdi->Bookmark($bookmark, 1, 0, '', '', array(0, 0, 0)); } } } } error_reporting($old_error); return $fpdi->Output('ignored.pdf', 'S'); }
function split_multi_pdf($arrayOfFiles) { $new_path = storage_path() . '/Macyspos'; if (!is_dir($new_path)) { // Will make directories under end directory that don't exist // Provided that end directory exists and has the right permissions mkdir($new_path, 0777, true); } foreach ($arrayOfFiles as $file) { $tempArrayOfPos = array(); $tempArrayOfPos = $this->getArrayOfPOs($file); $pdf = new FPDI(); $pagecount = $pdf->setSourceFile($file); // How many pages? for ($i = 1; $i <= $pagecount; $i++) { $singleItem = $tempArrayOfPos[$i - 1]; // dd($singleItem); $tempPackingList = MacysPackingList::where('po', '=', $singleItem['PO'])->first(); if ($tempPackingList == null) { $new_pdf = new FPDI(); $new_pdf->AddPage(); $new_pdf->setSourceFile($file); $newPackingList = new MacysPackingList(); $newPackingList->po = trim($singleItem['PO']); $newPackingList->shipterms = trim($singleItem['shipterms']); $new_pdf->useTemplate($new_pdf->importPage($i)); try { $new_filename = storage_path() . '/Macyspos/' . $singleItem['PO'] . '.pdf'; $newPackingList->pathToFile = $new_filename; $new_pdf->Output($new_filename, "F"); $newPackingList->save(); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } } } }
protected function execute(InputInterface $input, OutputInterface $output) { $id = $input->getArgument('id'); $pdffile = $input->getArgument('pdf'); $em = $this->getContainer()->get('doctrine'); $tab = $this->csv($pdffile); $template = $em->getRepository('PrintBundle:Template')->find($id); $path = $this->getContainer()->get('kernel')->getRootDir() . '/../web/uploads/pdf/' . $template->getPdffile(); $width = $template->getWidth(); $height = $template->getHeight(); $orientation = $height > $width ? 'P' : 'L'; $custom_layout = array($width, $height); $i = 1; foreach ($tab as $key => $value) { $pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false); $pdf->setPageOrientation($orientation); $pdf->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(true, 40); $pdf->setFontSubsetting(false); // add a page $pdf->AddPage($orientation); $pdf->setSourceFile($path); $_tplIdx = $pdf->importPage(1); $size = $pdf->useTemplate($_tplIdx, 0, 0, $width, true); foreach ($template->getChildactivity() as $opt) { $pdf->SetXY($opt->getX(), $opt->getY()); $pdf->SetFont($opt->getFont(), '', $opt->getFontsize() * 2); // echo $opt->getFontsize()."\n"; $pdf->Cell($opt->getWidth(), $opt->getHeight(), $value[$opt->getName()]); } //$pdf->Cell(0, $size['h'], 'TCPDF and FPDI'); // echo $template->getId(); $pdf->Output($this->getContainer()->get('kernel')->getRootDir() . '/../web/folder/pdf' . $template->getId() . "-{$i}.pdf", 'F'); $i++; } }
$pdf->Cell(20, 6, toStr(number_format($row["OTROS"], 2, ",", ".")), 0, 0, 'R'); $pdf->Cell(20, 6, toStr(number_format($row["ANTICIPO_EXP"], 2, ",", ".")), 0, 0, 'R'); $total += $row["ANTICIPO_EXP"]; $pdf->Ln(6); } $pdf->Ln(6); $pdf->Line(10, $pdf->GetY(), 200, $pdf->GetY()); $pdf->Ln(6); $pdf->Cell(190, 6, 'Total Bs.: ' . number_format($total, 2, ",", "."), 0, 1, 'R'); $tmpFile = 'tmp' . time() . '.pdf'; $pdf->Output($tmpFile, 'F'); $pdf = new FPDI(); $pdf->AddPage(); $pdf->setSourceFile($tmpFile); $box = '/MediaBox'; $tplIdx = $pdf->importPage(1, $box); $pdf->useTemplate($tplIdx, 5, -55, 160); $pdf->Output(); unlink($tmpFile); break; case "listapacmed": $titulo = "Lista de pacientes por día"; $pdf = new PDF(); $pdf->SetCompression(true); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Arial', '', 10); $smed = mssql_result(mssql_query("select nombre_prv from tbproveedores where codigo_prv='{$med}'"), 0, 0); $sql = mssql_query("\n\t\tSET LANGUAGE Spanish\n\t\tselect \n\t\t\tCODIGO_CIT, \n\t\t\tTURNO_CIT,\n\t\t\tPACIENTE_CIT,\n\t\t\t(select nombre_pac from tbpacientes where codigo_pac = paciente_cit) as paciente \n\t\t\tfrom tbcitas where \n\t\t\tproveedor_cit = '{$med}' and baremo_cit='{$esp}' and \n\t\t\tconvert(char(10),fecha_cit,126)='{$dd}' order by turno_cit asc\n\t\t"); $pdf->Cell(100, 6, toStr("Fecha: " . date("d/m/Y", strtotime($dd))), 0, 1); $pdf->Cell(100, 6, toStr("Médico: " . $smed), 0, 1);
public function save_design() { if ($this->input->post('mode') == 'edit') { $this->db->delete('designs', array('id' => $this->input->post('design_id'))); } $faceMacket = str_replace('http://klever.media/', '', $this->input->post('faceMacket')); $backMacket = str_replace('http://klever.media/', '', $this->input->post('backMacket')); $face = $this->input->post('face'); $back = $this->input->post('back'); // get all fonts $query = $this->db->get('fonts'); $fonts = array(); foreach ($query->result() as $font) { $fonts[$font->family] = $font->source; } // generate pdf face template name and preview name $face_pdf = 'uploads/redactor/face_' . md5(microtime(true)) . '.pdf'; $face_preview = 'uploads/redactor/face_' . md5(microtime(true)) . '.jpg'; // convert face image to pdf $img = new Imagick($faceMacket); $img->setresolution(300, 300); $img->setcolorspace(Imagick::COLORSPACE_CMYK); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->setimageformat('pdf'); $img->writeimage($face_pdf); // include TCPDF ana FPDI include_once APPPATH . 'libraries/tcpdf/tcpdf.php'; include_once APPPATH . 'libraries/tcpdf/fpdi.php'; include_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php'; $fontMaker = new TCPDF_FONTS(); // создаём лист $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false); $pdf->SetMargins(0, 0, 0, true); $pdf->AddPage('L'); // загрузим ранее сохранённый шаблон $pdf->setSourceFile($face_pdf); $pdf->SetMargins(0, 0, 0, true); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, null, null, 0, 0, true); // установим опции для pdf $pdf->setCellHeightRatio(1); $pdf->setCellPaddings(0, 0, 0, 0); $pdf->setCellMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(false, 0); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); if (!empty($face)) { // отрисуем сначала изображения лица foreach ($face as $item) { if ($item['type'] == 'image') { $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300); } } // потом текст на лице foreach ($face as $item) { if ($item['type'] == 'text') { $cmyk = $this->rgbToCmyk($item['color']); $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100); // set font $tcpdfFont = $fontMaker->addTTFfont(realpath('fonts/redactor/' . $fonts[$item['font']])); $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false'); $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false); } } } // сохраним пдф лица $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf, 'F'); // сделаем превью для пользователя $im = new Imagick(); $im->setResolution(300, 300); $im->readimage($face_pdf . '[0]'); $im->flattenimages(); $im->setImageFormat('jpg'); $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $im->writeImage($face_preview); $im->clear(); $im->destroy(); //exec('$ convert ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf . ' ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_preview); // есть ли оборот if (!empty($backMacket)) { // generate pdf back template name and preview name $back_pdf = 'uploads/redactor/back_' . md5(microtime(true)) . '.pdf'; $back_preview = 'uploads/redactor/back_' . md5(microtime(true)) . '.jpg'; // convert back image to pdf $img = new Imagick($backMacket); $img->setresolution(300, 300); $img->setcolorspace(Imagick::COLORSPACE_CMYK); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->setimageformat('pdf'); $img->writeimage($back_pdf); // создаём лист $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false); $pdf->AddPage('L'); // загрузим ранее сохранённый шаблон $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf); $pdf->SetMargins(0, 0, 0, true); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, null, null, 0, 0, true); // установим опции для pdf $pdf->SetMargins(0, 0, 0, true); $pdf->setCellHeightRatio(1); $pdf->setCellPaddings(0, 0, 0, 0); $pdf->setCellMargins(1, 1, 1, 1); $pdf->SetAutoPageBreak(false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); if (!empty($back)) { // отрисуем сначала изображения оборота foreach ($back as $item) { if ($item['type'] == 'image') { $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300); } } // потом текст на обороте foreach ($back as $item) { if ($item['type'] == 'text') { $cmyk = $this->rgbToCmyk($item['color']); $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100); // set font $tcpdfFont = $fontMaker->addTTFfont($_SERVER['DOCUMENT_ROOT'] . '/fonts/redactor/' . $fonts[$item['font']]); $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false'); $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false); } } } // сохраним пдф оборота $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf, 'F'); // сделаем превью для пользователя $im = new Imagick(); $im->setResolution(300, 300); $im->readimage($back_pdf . '[0]'); $im->setImageFormat('jpg'); $im->flattenimages(); $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $im->writeImage($back_preview); $im->clear(); $im->destroy(); } $this->db->insert('products', array('name' => 'cards_pvc', 'tiraj' => 100, 'weight' => 0.5, 'price' => 0.49, 'cost' => 49, 'macket' => 'my_macket')); $product_id = $this->db->insert_id(); $this->db->insert('designs', array('product_id' => $product_id, 'theme_id' => $this->input->post('theme'), 'face_background' => $faceMacket, 'back_background' => empty($backMacket) ? NULL : $backMacket, 'face' => $face_preview, 'back' => empty($back_preview) ? '' : $back_preview, 'type' => 'system')); $design_id = $this->db->insert_id(); $options = array(); if (!empty($face)) { foreach ($face as $item) { if ($item['type'] == 'text') { $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']); } else { $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL); } } } if (!empty($back)) { foreach ($back as $item) { if ($item['type'] == 'text') { $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']); } else { $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL); } } } if (count($options) > 0) { $this->db->insert_batch('design_options', $options); } echo 'OK'; }
public function view_sign_oc(){ require_once('./assets/fpdf17/fpdf.php'); require_once('./assets/fpdf17/fpdi.php'); $oc_id=$this->uri->segment(3,''); // init pce data $oc_dat=$this->m_oc->get_oc_by_id($oc_id); $project=$this->m_project->get_project_by_id($oc_dat->project_id); //init sign pic $ae_sign_user_dat=$this->m_user->get_user_by_login_name($project->project_cs); $ae_sign_filename="no"; if (isset($ae_sign_user_dat->sign_filename)) { $ae_sign_filename=$ae_sign_user_dat->sign_filename; } $finance_sign_dat=$this->m_user->get_user_by_login_name($oc_dat->fc_sign); $finance_sign_filename="no"; if (isset($finance_sign_dat->sign_filename)) { $finance_sign_filename=$finance_sign_dat->sign_filename; } // initiate FPDI $pdf = new FPDI(); // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น angsana $pdf->AddFont('angsana','','angsa.php'); // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana $pdf->AddFont('angsana','B','angsab.php'); // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana $pdf->AddFont('angsana','I','angsai.php'); // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana $pdf->AddFont('angsana','BI','angsaz.php'); // get the page count $pageCount = $pdf->setSourceFile("./media/real_pdf/".$oc_dat->filename); // iterate through all pages for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { // import a page $templateId = $pdf->importPage($pageNo); // get the size of the imported page $size = $pdf->getTemplateSize($templateId); // create a page (landscape or portrait depending on the imported page size) if ($size['w'] > $size['h']) { $pdf->AddPage('L', array($size['w'], $size['h'])); } else { $pdf->AddPage('P', array($size['w'], $size['h'])); } // use the imported page $pdf->useTemplate($templateId); $pdf->SetTextColor(0,0,0); $pdf->SetFont('angsana','B',14); $pdf->SetXY(5, 5); //$pdf->Write(8, 'A complete document imported with FPDI'); //// temporaly disable if ($finance_sign_filename!="no"&&$finance_sign_filename!=""&&$finance_sign_filename!=null) { //$pdf->Image("./media/sign_photo/".$finance_sign_filename,100,10,40,0); } if ($ae_sign_filename!="no"&&$ae_sign_filename!=""&&$ae_sign_filename!=null) { //$pdf->Image("./media/sign_photo/".$ae_sign_filename,100,110,40,0); } //$pdf->Image("images/play.png",100,100,100,0); } $new_filename=$oc_dat->oc_no."_A.pdf"; // Output the new PDF //@unlink("./media/real_pdf/".$new_filename); $pdf->Output($new_filename,"I"); //redirect("media/real_pdf/".$new_filename); }
function generateFundingStatusReport($conn) { global $gTEXT; global $pdf; $ItemGroup = $_POST['ItemGroup']; $lan = $_POST['lan']; if ($lan == 'en-GB') { $SITETITLE = SITETITLEENG; } else { $SITETITLE = SITETITLEFRN; } $CountryName = $_POST['CountryName']; $Year = $_POST['Year']; require_once 'tcpdf/tcpdf.php'; require_once 'fpdf/fpdi.php'; $pdf = new FPDI(); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->AddPage($orientation = L, $format = 'Letter', $keepmargins = false, $tocpage = false); $pdf->SetFillColor(255, 255, 255); $html_head = "<span style='text-align:center;font-size:10px;'><b>" . $SITETITLE . "</b></span><br>\n\t<span style='text-align:center;font-size:10px;'><b>" . $gTEXT['Funding Status Report of'] . " " . $CountryName . " " . $gTEXT['on'] . " " . $Year . "</b></span><br>\n\t<span style='text-align:center;font-size:10px;'><b>" . $gTEXT['Product Group'] . ": " . $ItemGroup . "</b></span>"; $html = ' <!-- EXAMPLE OF CSS STYLE --> <style> </style> <body> </body>'; $pdf->writeHTMLCell(0, 0, 15, '', $html_head, '', 1, 1, false, 'C', true, $spacing = 0); $pdf->setSourceFile("pdfslice/FundingStatusChart.pdf"); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, 0, 0, 500); }
function generatePatientTrendReport($conn) { global $gTEXT; $CountryName = $_POST['CountryName']; require_once 'tcpdf/tcpdf.php'; require_once 'fpdf/fpdi.php'; $pdf = new FPDI(); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->AddPage(); $pdf->SetFillColor(255, 255, 255); $StartMonthId = $_POST['StartMonthId']; $StartYearId = $_POST['StartYearId']; $EndMonthId = $_POST['EndMonthId']; $EndYearId = $_POST['EndYearId']; $frequencyId = 1; if ($_POST['MonthNumber'] != 0) { $months = $_POST['MonthNumber']; $monthIndex = date("m"); $yearIndex = date("Y"); settype($yearIndex, "integer"); if ($monthIndex == 1) { $monthIndex = 12; $yearIndex = $yearIndex - 1; } else { $monthIndex = $monthIndex - 1; } $months = $months - 1; $d = cal_days_in_month(CAL_GREGORIAN, $monthIndex, $yearIndex); $EndYearMonth = $yearIndex . "-" . str_pad($monthIndex, 2, "0", STR_PAD_LEFT) . "-" . $d; $EndYearMonth = date('Y-m-d', strtotime($EndYearMonth)); $StartYearMonth = $yearIndex . "-" . str_pad($monthIndex, 2, "0", STR_PAD_LEFT) . "-" . "01"; $StartYearMonth = date('Y-m-d', strtotime($StartYearMonth)); $StartYearMonth = date("Y-m-d", strtotime(date("Y-m-d", strtotime($StartYearMonth)) . "-" . $months . " month")); } else { $startDate = $StartYearId . "-" . $StartMonthId . "-" . "01"; $StartYearMonth = date('Y-m-d', strtotime($startDate)); $d = cal_days_in_month(CAL_GREGORIAN, $EndMonthId, $EndYearId); $endDate = $EndYearId . "-" . $EndMonthId . "-" . $d; $EndYearMonth = date('Y-m-d', strtotime($endDate)); } $monthListShort = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec'); $quarterList = array(3 => 'Jan-Mar', 6 => 'Apr-Jun', 9 => 'Jul-Sep', 12 => 'Oct-Dec'); $output = array('aaData' => array()); $aData = array(); $output2 = array(); if ($frequencyId == 1) { $monthQuarterList = $monthListShort; } else { $monthQuarterList = $quarterList; } $month_list = array(); $startDate = strtotime($StartYearMonth); $endDate = strtotime($EndYearMonth); $index = 0; // while ($endDate >= $startDate) { // $month_list[$index] = date('M Y',$startDate); // $index++; // $startDate = strtotime( date('Y/m/d',$startDate).' 1 month'); // } while ($endDate >= $startDate) { if ($frequencyId == 1) { $monthid = date('m', $startDate); settype($monthid, "integer"); $ym = $monthListShort[$monthid] . ' ' . date('Y', $startDate); $month_list[$index] = $ym; $output['Categories'][] = $ym; $index++; } else { $monthid = date('m', $startDate); settype($monthid, "integer"); if ($monthid == 3 || $monthid == 6 || $monthid == 9 || $monthid == 12) { $ym = $quarterList[$monthid] . ' ' . date('Y', $startDate); $month_list[$index] = $ym; $output['Categories'][] = $ym; $index++; } } $startDate = strtotime(date('Y/m/d', $startDate) . ' 1 month'); } $html = ' <!-- EXAMPLE OF CSS STYLE --> <style> </style> <body> <h4 style="text-align:left;"><b>' . $gTEXT['Patient Trend Time Series Report of'] . ' ' . $CountryName . ' ' . $gTEXT['from'] . ' ' . date('M,Y', strtotime($StartYearMonth)) . ' ' . $gTEXT['to'] . ' ' . date('M,Y', strtotime($EndYearMonth)) . '</b></h4> </body>'; $pdf->writeHTMLCell(0, 0, 17, '', $html, '', 1, 1, false, 'L', true, $spacing = 0); $pdf->setSourceFile("pdfslice/PatientTrendChart.pdf"); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx, 0, 0, 200); //=====================================================Patient Trend Time Series Table======================================================= $lan = $_REQUEST['lan']; $countryId = $_POST['Country']; $itemGroupId = $_POST['ItemGroupId']; //$frequencyId = 1;// $_POST['FrequencyId']; if ($lan == 'en-GB') { $serviceTypeName = 'ServiceTypeName'; } else { $serviceTypeName = 'ServiceTypeNameFrench'; } // ////////////////// $sQuery = "SELECT a.ServiceTypeId, IFNULL(SUM(c.TotalPatient),0) TotalPatient\n\t\t\t, {$serviceTypeName} ServiceTypeName, a.STL_Color,c.Year,c.MonthId\n FROM t_servicetype a\n INNER JOIN t_formulation b ON a.ServiceTypeId = b.ServiceTypeId\n Inner JOIN t_cnm_patientoverview c \t\n\t\t\t\t\tON (c.FormulationId = b.FormulationId \n\t\t\t\t\t\tand STR_TO_DATE(concat(year,'/',monthid,'/02'), '%Y/%m/%d') \n\t\t\t\t\t\tbetween '" . $StartYearMonth . "' and '" . $EndYearMonth . "'\n \t\tAND (c.CountryId = " . $countryId . " OR " . $countryId . " = 0)\n\t\t\t\t\t\tAND (c.ItemGroupId = " . $itemGroupId . " OR " . $itemGroupId . " = 0)) \t\t \n GROUP BY a.ServiceTypeId, {$serviceTypeName}, a.STL_Color\n\t\t\t\t, c.Year, c.MonthId\n\t\t\t\tHAVING TotalPatient > 0\n\t\t ORDER BY a.ServiceTypeId asc,c.Year asc, c.MonthId asc;"; //echo $sQuery; $rResult = safe_query($sQuery); $total = mysql_num_rows($rResult); $tmpServiceTypeId = -1; $countServiceType = 1; $count = 1; $preServiceTypeName = ''; if ($total == 0) { return; } //echo 'Rubel'; if ($total > 0) { while ($row = mysql_fetch_assoc($rResult)) { if (!is_null($row['TotalPatient'])) { settype($row['TotalPatient'], "integer"); } if ($tmpServiceTypeId != $row['ServiceTypeId']) { if ($count > 1) { array_unshift($output2, $countServiceType, $preServiceTypeName); $aData[] = $output2; unset($output2); $countServiceType++; } $count++; $preServiceTypeName = $row['ServiceTypeName']; $count = 0; while ($count < count($month_list)) { $output2[] = null; $count++; } $dataMonthYear = $monthQuarterList[$row['MonthId']] . ' ' . $row['Year']; $count = 0; while ($count < count($month_list)) { if ($month_list[$count] == $dataMonthYear) { $output2[$count] = $row['TotalPatient']; } $count++; } $tmpServiceTypeId = $row['ServiceTypeId']; } else { $dataMonthYear = $monthQuarterList[$row['MonthId']] . ' ' . $row['Year']; $count = 0; while ($count < count($month_list)) { if ($month_list[$count] == $dataMonthYear) { $output2[$count] = $row['TotalPatient']; } $count++; } $tmpServiceTypeId = $row['ServiceTypeId']; } } array_unshift($output2, $countServiceType, $preServiceTypeName); $aData[] = $output2; //print_r($month_list); $col = '<tr><th width="20" align="center"><b>SL</b></th>'; $col .= '<th width="35" align="left"><b>' . $gTEXT['Patient Type'] . '</b></th>'; $f = 0; for ($f = 0; $f < count($month_list); $f++) { $col .= '<th width="30" align="right"><b>' . $month_list[$f] . '</b></th>'; } $col .= '</tr>'; $p = 0; for ($p = 0; $p < count($aData); $p++) { $col .= '<tr>'; for ($i = 0; $i < count($aData[$p]); $i++) { $col .= '<td>' . $aData[$p][$i] . '</td>'; } $col .= '</tr>'; } $i = 1; /* $col = '<tr><th width="38" align="center"><b>SL</b></th>'; $col.= '<th width="38" align="left"><b>'.$gTEXT['Patient Type'].'</b></th>'; $f=0; for($f = 0; $f<count($rmonth_name); $f++){ $col.= '<th width="38" align="right"><b>'.$rmonth_name[$f].'</b></th>'; } $col.='</tr><tr>'; $x=0; for($x = 0; $x<count($art); $x++){ $col.= '<td width="38" align="right"><b>'.$art[$x].'</b></td>'; } $col.='</tr><tr>'; $x=0; for($x = 0; $x<count($rtk); $x++){ $col.= '<td width="38" align="right"><b>'.$rtk[$x].'</b></td>'; } $col.='</tr><tr>'; $x=0; for($x = 0; $x<count($pmtct); $x++){ $col.= '<td width="38" align="right"><b>'.$pmtct[$x].'</b></td>'; } $col.='</tr>'; */ $html_head = "<span><b>" . $gTEXT['Patient Trend Time Series Data List'] . "</b></span>"; $pdf->SetFont('dejavusans', '', 9); $pdf->writeHTMLCell(0, 0, 17, 125, $html_head, '', 0, 0, false, 'L', true); $html = ' <!-- EXAMPLE OF CSS STYLE --> <style> td{ height: 6px; line-height:3px; } </style> <body> <table width="550px" border="0.5" style="margin:0px auto;">' . $col . '</table></body>'; $pdf->SetFont('dejavusans', '', 7); $pdf->writeHTMLCell(0, 0, 15, 140, $html, '', 1, 1, false, 'C', true); $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/PatientTrendReport.pdf'; if (file_exists($filePath)) { unlink($filePath); } $pdf->Output('pdfslice/PatientTrendReport.pdf', 'F'); echo 'PatientTrendReport.pdf'; } else { echo 'Processing Error'; } }
public function pdfImg($file) { require_once $_SERVER['DOCUMENT_ROOT'] . 'tyj_oa/Public/fpdf/fpdf.php'; require_once $_SERVER['DOCUMENT_ROOT'] . 'tyj_oa/Public/fpdi/fpdi.php'; $pdf = new FPDI(); $pageCount = $pdf->setSourceFile($file); for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { $templateId = $pdf->importPage($pageNo); $size = $pdf->getTemplateSize($templateId); if ($size['w'] > $size['h']) { $pdf->AddPage('L', array($size['w'], $size['h'])); } else { $pdf->AddPage('P', array($size['w'], $size['h'])); } if ($pageNo == $pageCount) { $img = $_SERVER['DOCUMENT_ROOT'] . get_save_url() . D('user')->where('id = ' . get_user_id())->getField('pic_yin'); $pdf->Image($img, 150, 250, 0, 20); } $pdf->useTemplate($templateId); $pdf->SetFont('Helvetica'); $pdf->SetXY(5, 5); } $pdf->Output($file); }
/** * Determine if the email should actually be sent and setup email merge variables * * @since 0.1 * @param int $order_id */ public function trigger($order_id) { global $woocommerce; // bail if no order ID is present if (!$order_id) { return; } // setup order object $this->object = new WC_Order($order_id); //check if is downloadbale if (!$this->object->has_downloadable_item()) { return; } // replace variables in the subject/headings $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); //To get the dir, use: dirname($path) require_once 'fpdf/fpdf.php'; require_once 'fpdi/fpdi.php'; if (!$this->is_enabled() || !$this->get_recipient()) { return; } $upload_dir = wp_upload_dir(); // Array of key => value pairs //cosntruct ticket temp dir $tickettemp = $upload_dir['basedir'] . '/tickets_temp'; if (!file_exists($tickettemp)) { mkdir($tickettemp, 0755, true); } $items = $this->object->get_items(); $varation_ids = array(); $metaorder = get_post_meta($this->object->id); $emaailid = $this->object->billing_email; $downloadlinks = array(); $i = 0; foreach ($items as $key => $value) { $x = 1; $getprod = $this->object->get_product_from_item($value); $getdownload = $this->object->get_item_downloads($value); if ($getprod->product_type != 'ticket') { break; } if (empty($getdownload)) { break; } $qty = intval($value['qty']); while ($x <= $qty) { $x++; foreach ($getdownload as $keysub => $valuesub) { $downlink = $valuesub['file']; } $path = $_SERVER['DOCUMENT_ROOT'] . parse_url($downlink, PHP_URL_PATH); $pdfout = $tickettemp . '/ticket_' . $this->object->id . '' . $value['product_id'] . '' . $x . '.pdf'; $downloadlinks[$i] = $pdfout; $pagenum = 1; $pdf = new FPDI(); $pdf->AddPage(); //Set the source PDF file $pagecount = $pdf->setSourceFile($path); //Import the first page of the file $tpl = $pdf->importPage($pagenum); //Use this page as template $pdf->useTemplate($tpl); $getfooterY = $pdf->h - 35; //Select Arial italic 8 $pdf->SetY($getfooterY); $pdf->SetFont('Arial', 'I', 10); $pdf->Cell(0, 10, 'Ticket id: ' . $this->object->id . '' . $value['product_id'] . '' . $x, 0, 0, 'C'); $pdf->Output($pdfout, "F"); $i++; } } /* $email_class = new WC_Email(); remove_action( 'woocommerce_after_resend_order_email', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); echo "<pre>"; var_dump( $this->emails ); echo "</pre>"; var_dump( $downloadlinks ); var_dump( $items ); var_dump( $emaailid); var_dump( $this->object ); */ // woohoo, send the email! $this->send($this->get_recipient() . ', ' . $this->object->billing_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $downloadlinks); //Delete the temp tickets foreach ($downloadlinks as $key => $value) { chmod($value, 0777); if (file_exists($value)) { unlink($value); } } //die(); }
} # incluimos la libreria fdpf # http://www.fpdf.org/ require_once 'fpdf/fpdf17/fpdf.php'; # incluimos la libreria fpdi # http://www.setasign.com/products/fpdi/about/ require_once 'fpdf/FPDI-1.5.2/fpdi.php'; # inicializamos el objeto $pdf = new FPDI(); # definimos el archivo pdf a leer. Nos devuel el numero de paginas $id = $_REQUEST['archivo']; $enlace = $rutaArchivos . $id; $paginas = $pdf->setSourceFile($enlace); for ($pagina = 1; $pagina < $paginas + 1; $pagina++) { # importamos cada una de las paginas $templateId = $pdf->importPage($pagina); # obtenemos el temaño de cada hoja $size = $pdf->getTemplateSize($templateId); // create a page definiendo el formato y tamaños if ($size['w'] > $size['h']) { $pdf->AddPage('L', array($size['w'], $size['h'])); } else { $pdf->AddPage('P', array($size['w'], $size['h'])); } $pdf->useTemplate($templateId); } # devolvemos el documento $pdf->Output(); ?>
/** * Simple helper function which actually merges a given array of document-paths * @param $paths * @return string The created document's url */ private function mergeDocuments($paths) { include_once 'engine/Library/Fpdf/fpdf.php'; include_once 'engine/Library/Fpdf/fpdi.php'; $pdf = new FPDI(); foreach ($paths as $path) { $numPages = $pdf->setSourceFile($path); for ($i = 1; $i <= $numPages; $i++) { $template = $pdf->importPage($i); $size = $pdf->getTemplateSize($template); $pdf->AddPage('P', array($size['w'], $size['h'])); $pdf->useTemplate($template); } } $hash = md5(uniqid(rand())); $pdf->Output($hash . '.pdf', "D"); }
function showForm($data = "", $msg = "") { global $t, $db, $sesIdUsuario, $hoy, $usuario; $idReg = $data[idReg]; $idPedido = $data[idPedido]; //echo "ID_PEDIDO : $idPedido <hr>"; $t->set_file("page", "opGuia.inc.html"); // ----------------------------------------- // Datos del Pedido // ----------------------------------------- $sql = "select id_cliente,ori,des,mov,bkg,pos_fec,pos_hor,pos_min,ori,des, "; $sql .= "destinatario,destinatario_dom "; $sql .= "from PEDIDO where id_pedido='{$idPedido}' "; $db->query($sql); while ($db->next_record()) { $idCliente = $db->f(id_cliente); $cliente = getValueTable("cliente", "CLIENTE", "id_cliente", $idCliente); $ori = $db->f(ori); $des = $db->f(des); $mov = $db->f(mov); $bkg = $db->f(bkg); $posFec = $db->f(pos_fec); $posHor = $db->f(pos_hor); $posMin = $db->f(pos_min); $pos = "{$posFec} {$posHor}:{$posMin}"; $ori = $db->f(ori); $des = $db->f(des); $ruta = "{$ori} / {$des}"; $destinatario = $db->f(destinatario); $destinatarioDom = $db->f(destinatario_dom); } $t->set_var(array("ID_REG" => $idReg, "ID_PEDIDO" => $idPedido, "ACTION" => $PHP_SELF, "MENSAJE" => "", "CLIENTE" => $cliente, "ORI" => $ori, "DES" => $des, "MOV" => $mov, "CANCELADO_DETALLE" => "", "IMPRIMIR" => "<a href=\"javascript:ventanaNueva('opGuiaImp.php?idReg={$idReg}',850,600)\"><img src=\"../images/imp.png\" border=\"0\" height=\"30\" width=\"30\"></a>", "PDF" => "")); // Consultar si esta cancelada la Guia de embarque. $stRegGE = getValueTable("st_reg", "GUIA", "id_guia", $idReg); $bajaIdUsr = getValueTable("baja_id_usr", "GUIA", "id_guia", $idReg); $bajaFec = getValueTable("baja_fec", "GUIA", "id_guia", $idReg); if ($stRegGE == "B") { $bajaUsr = getValueTable("usuario", "USUARIO", "id_usuario", $bajaIdUsr); $bajaDetalle = "<font color=red>**CANCELADO**<br>Por: {$bajaUsr}<br>Fecha : {$bajaFec}</font>"; $t->set_var("CANCELADO_DETALLE", "{$bajaDetalle}"); } else { $stRegColor = "class=\"color3\""; $bajaDetalle = ""; $t->set_var("BAJA", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','{$idGuia}','baja')\"><img src=\"../images/b_del.png\" border=0></a>"); } if (empty($idReg) || $idReg == 0) { $op = "nuevo"; } elseif ($stRegGE == "B") { $op = "cancelado"; $t->set_var("GUARDAR", ""); $t->set_var("ACTUALIZAR", ""); $t->set_var("IMPRIMIR", ""); } else { $op = "editar"; } switch ($op) { case "editar": if ($usuario->havePerm("1,9", $_SESSION['sesArrPerms'])) { // 9 : [Transporte] Captura Pedidos $t->set_var("GUARDAR", ""); $t->set_var("ACTUALIZAR", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','{$idReg}','update')\">Actualizar Datos</a>"); } else { $t->set_var("GUARDAR", ""); $t->set_var("ACTUALIZAR", ""); } break; case "nuevo": if ($usuario->havePerm("1,9", $_SESSION['sesArrPerms'])) { if (!empty($idPedido)) { $t->set_var("GUARDAR", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','','rec')\">Guardar</a>"); $t->set_var("ACTUALIZAR", ""); } else { $t->set_var("GUARDAR", "<font color=\"red\"><b>ERROR : PRIMERO SELECCIONE UN PEDIDO Y LUEGO CREE UNA GUIA DE EMBARQUE.</b></font>"); $t->set_var("ACTUALIZAR", ""); } } else { $t->set_var("GUARDAR", ""); $t->set_var("ACTUALIZAR", ""); } break; } // -------------------------- // CONSULTA DE GUIA // -------------------------- if ($idReg > 0) { $sql = "select * from GUIA where id_guia='{$idReg}'"; $db->query($sql); while ($db->next_record()) { $serie = $db->f(serie); $folio = $db->f(folio); $data[folio] = $serie . $folio; //$data[facturaS] = $db->f(factura_s); $data[factura] = $db->f(factura); $idConte = $db->f(id_contenedor); $idEquipo = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte); $data[conte] = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte); $data[equipo] = getValueTable("equipo", "EQUIPO", "id_equipo", $idEquipo); $data[sello] = $db->f(sello); $data[flete] = $db->f(flete); $data[seguro] = $db->f(seguro); $data[otroCosto] = $db->f(otro_costo); $data[diceContener] = $db->f(dice_contener); $data[mercancia] = $db->f(mercancia); $data[bulto] = $db->f(bulto); $data[operador] = $db->f(operador); $data[nota] = $db->f(nota); $data[traUni] = $db->f(tra_uni); $data[traPla] = $db->f(tra_pla); $data[chaUni] = $db->f(cha_uni); $data[chaPla] = $db->f(cha_pla); $data[terLlega] = $db->f(ter_llega); $data[terSale] = $db->f(ter_sale); $data[terVacLlega] = $db->f(ter_vac_llega); $data[terVacSale] = $db->f(ter_vac_sale); $data[referencia] = $db->f(referencia); $data[tonelaje] = $db->f(tonelaje); $data[valorDec] = $db->f(valor_dec); $capIdUsr = $db->f(cap_id_usr); $capFec = $db->f(cap_fec); $modIdUsr = $db->f(mod_id_usr); $modFec = $db->f(mod_fec); $capUsr = getValueTable("usuario", "USUARIO", "id_usuario", $capIdUsr); $modUsr = getValueTable("usuario", "USUARIO", "id_usuario", $modIdUsr); $data[maniobra] = $db->f(maniobra); $data[autopista] = $db->f(autopista); $data[clase] = $db->f(clase); $data[ruta] = $db->f(ruta); $data[gastosViaje] = $db->f(gastos_viaje); $data[dollyNum] = $db->f(dolly_num); $data[dollyPla] = $db->f(dolly_pla); } } // Combos if ($data[maniobra] == "M") { $t->set_var("MANI_SEL_M", "selected"); } if ($data[maniobra] == "C") { $t->set_var("MANI_SEL_C", "selected"); } if ($data[autopista] == "S") { $t->set_var("AUTOPISTA_SEL_S", "selected"); } if ($data[autopista] == "N") { $t->set_var("AUTOPISTA_SEL_N", "selected"); } // Combo Bulto if ($data[bulto] == "20-DC") { $t->set_var("20DCSEL", "selected"); } if ($data[bulto] == "40-DC") { $t->set_var("40DCSEL", "selected"); } if ($data[bulto] == "40-HC") { $t->set_var("40HCSEL", "selected"); } if ($data[bulto] == "20-RF") { $t->set_var("20RFSEL", "selected"); } if ($data[bulto] == "40-RF") { $t->set_var("40RFSEL", "selected"); } if ($data[bulto] == "20-OT") { $t->set_var("20OTSEL", "selected"); } if ($data[bulto] == "40-OT") { $t->set_var("40OTSEL", "selected"); } if ($data[bulto] == "20-FL") { $t->set_var("20FLSEL", "selected"); } if ($data[bulto] == "40-FL") { $t->set_var("40FLSEL", "selected"); } if ($data[bulto] == "20-TK") { $t->set_var("20TKSEL", "selected"); } if ($data[bulto] == "40-TK") { $t->set_var("40TKSEL", "selected"); } // Combo Clase de contenedor if ($data[clase] == "A") { $t->set_var("CLASESELA", "selected"); } if ($data[clase] == "B") { $t->set_var("CLASESELB", "selected"); } if ($data[clase] == "C") { $t->set_var("CLASESELC", "selected"); } if ($data[clase] == "D") { $t->set_var("CLASESELD", "selected"); } if ($data[clase] == "FG") { $t->set_var("CLASESELFG", "selected"); } if ($data[clase] == "GC") { $t->set_var("CLASESELGC", "selected"); } $folioX = $data[folio]; $t->set_var(array("FOLIO" => $folioX, "FACTURA_S" => $data[facturaS], "FACTURA" => $data[factura], "REFERENCIA" => $data[referencia], "TONELAJE" => $data[tonelaje], "VALOR_DEC" => $data[valorDec], "CONTENEDOR" => $data[conte], "EQUIPO" => $data[equipo], "SELLO" => $data[sello], "FLETE" => $data[flete], "MANIOBRA" => $data[maniobra], "SEGURO" => $data[seguro], "AUTOPISTA" => $data[autopista], "OTRO_COSTO" => $data[otroCosto], "MERCANCIA" => $data[mercancia], "DICE_CONTENER" => $data[diceContener], "OPERADOR" => $data[operador], "NOTA" => $data[nota], "TRA_UNI" => $data[traUni], "TRA_PLA" => $data[traPla], "CHA_UNI" => $data[chaUni], "CHA_PLA" => $data[chaPla], "TER_LLEGA" => $data[terLlega], "TER_SALE" => $data[terSale], "TER_VAC_LLEGA" => $data[terVacLlega], "TER_VAC_SALE" => $data[terVacSale], "CAPTURO" => "{$capUsr} / {$capFec}", "MODIFICO" => "{$modUsr} / {$modFec}", "RUTA" => $data[ruta], "GASTOS_VIAJE" => $data[gastosViaje], "DOLLY_NUM" => $data[dollyNum], "DOLLY_PLA" => $data[dollyPla])); // ""=>$data[], //$facS = $data[facturaS]; $facX = $data[factura]; if (preg_match("/(.{0,2})(.*)/", $facX, $parts)) { $facS = $parts[1]; $facN = $parts[2]; } if ($idReg > 0 && !empty($facN)) { // ---------------------------------------------- // PROCESO DE EDICION DE FACTURA-PDF // // 1. Comprobar que exista la factura original. // 2. Buscar todas las GE que tengan la misma factura relacionada. // 3. Consultar (Folio_serie,Folio,Contenedor,Tipo,Bkg,Posicionamiento,Ruta,etc. // 4. Generar nuevo PDF. // ---------------------------------------------- $facN2 = str_pad($facN, 7, 0, STR_PAD_LEFT); $filePdfOri = "OPE0606129RAF" . $facS . $facN2 . ".pdf"; $filePdfEdi = "OPE0606129RAF" . $facS . $facN2 . "_.pdf"; // Consultar datos GE con la misma Factura. unset($txtFac); unset($txtFac2); $numConte = 0; $sql = "select folio,id_contenedor "; $sql .= "from GUIA "; //$sql.="where factura_s='$facS' and factura='$facN' and st_reg<>'B' "; $sql .= "where factura='{$facX}' and st_reg<>'B' "; $db->query($sql); while ($db->next_record()) { $numConte++; $folioX = $db->f(folio); $folioS = substr($folioX, 0, 2); $folioN = substr($folioX, 2, 10); $idConte = $db->f(id_contenedor); $conte = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte); $idEq = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte); $equipo = getValueTable("equipo", "EQUIPO", "id_equipo", $idEq); // Si la cantidad de contenedores es mayor al limite, entonces 2do arreglo. $maxConte = 17; if ($numConte > $maxConte) { $txtFac2[] = "{$folioS} {$folioN} {$conte} {$equipo}"; } else { $txtFac[] = "{$folioS} {$folioN} {$conte} {$equipo}"; } } // --------------------------------------------------- // Editar factura. if (file_exists("../facturas/{$filePdfOri}")) { //$pdf =& new FPDI(); $pdf = new FPDI(); $pdf->AddPage(); //Set the source PDF file $pagecount = $pdf->setSourceFile("../facturas/{$filePdfOri}"); //Import the first page of the file $tpl = $pdf->importPage(1); //Use this page as template $pdf->useTemplate($tpl); $pdf->SetFont('Arial', '', 7); // PAGINA #1 // Inicializa la posición $destinatarioDom = str_replace("\n", "", $destinatarioDom); $destinatarioDom = str_replace("\r", "", $destinatarioDom); $pdf->SetXY(60, 90); $pdf->Cell(45, 5, "BKG : {$bkg} ", 0, 0, 'L'); $pdf->SetXY(60, 93); $pdf->Cell(45, 5, "POSICIONAMIENTO : {$pos} ", 0, 0, 'L'); $pdf->SetXY(60, 96); $pdf->Cell(45, 5, "RUTA : {$ruta}", 0, 0, 'L'); $pdf->SetXY(60, 99); $pdf->Cell(45, 5, "SALIDA DE VACIO : ? ", 0, 0, 'L'); $pdf->SetXY(60, 105); $pdf->Cell(60, 5, $destinatario, 0, 0, 'L'); // Seccionar a varias Cell, el domicilio del destinatario // Direccion de destinatario $s = $destinatarioDom; $s = strtoupper($s); $lenTl = strlen($s); // Conocer el numero de lineas $nlDes = $lenTl / 15; // El total de caracteres entre el ancho de 35 que es el max de caracteres x linea. $posIni = 0; $y = 109; for ($i = 1; $i <= $nlDes; $i++) { $txtX = substr($s, $posIni, 35); $pdf->SetXY(60, $y); $pdf->Cell(60, 4, $txtX, 0, 0, 'L'); $posIni = $posIni + 35; $y = $y + 3; } // --------------------------- $y = 90; foreach ($txtFac as $txt) { $pdf->SetXY(10, $y); $pdf->Cell(45, 5, $txt, 0, 0, 'L'); $y = $y + 3; } if ($numConte > $maxConte) { $pdf->SetXY(60, 130); $pdf->Cell(45, 5, "*** VER ANEXO *** VER ANEXO ***", 0, 0, 'L'); // PAGINA #2 $pdf->AddPage(); $y = 20; foreach ($txtFac2 as $txt2) { $pdf->SetXY(10, $y); $pdf->Cell(45, 5, "{$txt2}", 0, 0, 'L'); $y = $y + 3; if ($y == 266) { $y = 20; $pdf->AddPage(); } } } // Grabar archivo //echo "[$filePdfEdi]"; $pdf->Output("../facturas/{$filePdfEdi}", "F"); //$x = file_exists("../facturas/$filePdfEdi"); if (file_exists("../facturas/{$filePdfEdi}")) { $pdfImg = "<a href=\"javascript:ventanaNueva('../facturas/{$filePdfEdi}',800,600)\"><img src=\"../images/pdf.gif\" width=\"25\" hight=\"20\" border=0></a>"; } else { $pdfImg = ""; } $t->set_var("PDF", "{$pdfImg}"); } else { $t->set_var("PDF", ""); } } // ----------------------------------------------- // Control de mensajes // ------------------------------------------- if (!empty($msg)) { $canMsg = count($msg); if ($canMsg > 0) { foreach ($msg as $val) { $cadMsg .= $val . " <br>"; } $t->set_var(array("MENSAJE" => $cadMsg)); } } $t->pparse("out", "page"); }
function emarking_import_pdf_into_pdf(FPDI $pdf, $pdftoimport) { $originalpdfpages = $pdf->setSourceFile($pdftoimport); $pdf->SetAutoPageBreak(false); // Add all pages in the template, adding the header if it corresponds for ($pagenumber = 1; $pagenumber <= $originalpdfpages; $pagenumber++) { // Adding a page $pdf->AddPage(); $template = $pdf->importPage($pagenumber); $pdf->useTemplate($template, 0, 0, 0, 0, true); } }
function importPage($pageno, $boxName = '/CropBox') { $tplidx = parent::importPage($pageno, $boxName); $tpl =& $this->tpls[$tplidx]; $parser =& $tpl['parser']; // look for hyperlink annotations and store them in the template if (isset($parser->pages[$pageno - 1][1][1]['/Annots'])) { $annots = $parser->pages[$pageno - 1][1][1]['/Annots']; $annots = $this->resolve($parser, $annots); $links = array(); foreach ($annots[1] as $annot) { if ($annot[0] == PDF_TYPE_DICTIONARY) { // all links look like: << /Type /Annot /Subtype /Link /Rect [...] ... >> // but since not all the files contain links need to add a check if (isset($annot[1]['/Type'])) { if ($annot[1]['/Type'][1] == '/Annot' && $annot[1]['/Subtype'][1] == '/Link') { $rect = $annot[1]['/Rect']; if ($rect[0] == PDF_TYPE_ARRAY && count($rect[1]) == 4) { $x = $rect[1][0][1]; $y = $rect[1][1][1]; $x2 = $rect[1][2][1]; $y2 = $rect[1][3][1]; $w = $x2 - $x; $h = $y2 - $y; $h = -$h; } if (isset($annot[1]['/A'])) { $A = $annot[1]['/A']; if ($A[0] == PDF_TYPE_DICTIONARY && isset($A[1]['/S'])) { $S = $A[1]['/S']; // << /Type /Annot ... /A << /S /URI /URI ... >> >> if ($S[1] == '/URI' && isset($A[1]['/URI'])) { $URI = $A[1]['/URI']; if (is_string($URI[1])) { $uri = str_replace("\\000", '', trim($URI[1])); if (!empty($uri)) { $links[] = array($x, $y, $w, $h, $uri); } } // << /Type /Annot ... /A << /S /GoTo /D [%d 0 R /Fit] >> >> } else { if ($S[1] == '/GoTo' && isset($A[1]['/D'])) { $D = $A[1]['/D']; if ($D[0] == PDF_TYPE_ARRAY && count($D[1]) > 0 && $D[1][0][0] == PDF_TYPE_OBJREF) { $target_pageno = $this->findPageNoForRef($parser, $D[1][0]); if ($target_pageno >= 0) { $links[] = array($x, $y, $w, $h, $target_pageno); } } } } } } else { if (isset($annot[1]['/Dest'])) { $Dest = $annot[1]['/Dest']; // << /Type /Annot ... /Dest [42 0 R ...] >> if ($Dest[0] == PDF_TYPE_ARRAY && $Dest[0][1][0] == PDF_TYPE_OBJREF) { $target_pageno = $this->findPageNoForRef($parser, $Dest[0][1][0]); if ($target_pageno >= 0) { $links[] = array($x, $y, $w, $h, $target_pageno); } } } } } } } } } // echo "Links on page $pageno:\n"; // print_r($links); if (isset($links)) { $tpl['links'] = $links; } return $tplidx; }
private function _generatePdfSamplePage($filePath) { //error_reporting(E_ALL); //Zend_Loader::registerAutoload(false); //require_once('TCPDF.php'); require_once 'PdfTool/fpdf/fpdf.php'; require_once 'PdfTool/fpdi/fpdi.php'; // initiate FPDI $pdf = new FPDI(); // add a page $pdf->AddPage(); // set the sourcefile $pageCount = $pdf->setSourceFile($filePath); //print_r($pageCount); //die(); // 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, 10, 10, 100); // now write some text above the imported page $pdf->SetFont('Arial'); $pdf->SetTextColor(255, 0, 0); $pdf->SetXY(10, 10); $pdf->Write(0, "SAMPLE FOR VIEWING ONLY"); $pdf->Output('sample.pdf', 'I'); /*$pdf=new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output();*/ die; }
require_once($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_cotizacion/generar_grafico_comparativo.php"); $graficoOk = true; } catch (Exception $e) { $graficoOk = false; } // FIN - Generación de gráfico que va incrustado en el reporte.. if ($graficoOk) { $pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_cotizacion/plantillas/analisis_comparativo_costos.pdf"); $pdf->SetDrawColor(255, 255, 255); $pdf->SetFillColor(255, 255, 255); $pdf->AddPage(); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx); $pdf->SetFont("Arial", "B", 10); $pdf->Ln(33); $pdf->Cell(40); $pdf->Cell(144, 0, $row["RAZONSOCIAL"]); $pdf->Ln(6.6); $pdf->Cell(28); $pdf->Cell(36, 0, $row["CUIT"]); $pdf->Cell(16); $pdf->Cell(80, 0, $row["CIIU"]); $pdf->Ln(6.6);
} else { print "<meta http-equiv=\"Refresh\" content=\"0;URL=MainPage.php\">"; exit; } } if ($_SESSION['status'] == "admin") { $query = "SELECT * FROM `abiturients` WHERE `ab_id` = '" . $id . "'"; $sql = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($sql) == 1) { $row = mysql_fetch_assoc($sql); } } $pdf = new FPDI(); $pageCount = $pdf->setSourceFile("img/ugoda2014.pdf"); $pageNo = 1; $templateId = $pdf->importPage($pageNo); $size = $pdf->getTemplateSize($templateId); $pdf->AddPage('P', array($size['w'], $size['h'])); $pdf->useTemplate($templateId); $pdf->AddFont('Times', '', 'times.php'); $pdf->SetFont('Times', '', 10); $pdf->SetTextColor(0, 0, 0); $pdf->SetFontSize(11); $pdf->SetXY(35, 61); $pdf->Write(5, $row['lastname'] . " " . $row['firstname'] . " " . $row['patronymic']); $pdf->SetXY(55, 70); if ($row['type'] == "mag") { $pdf->Write(5, "6-й курс, " . $row['faculty']); } if ($row['type'] == "spc") { $pdf->Write(5, "5-й курс " . $row['faculty']);
if (in_array($cfile->name, $fnames)) { continue; } $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) {
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'); } }
function page4($employee_id) { $this->load->helper('settings'); $this->load->library('fpdf'); //define('FPDF_FONTPATH',$this->config->item('fonts_path')); $this->load->library('fpdi'); //print_r($personal_info); // initiate FPDI $pdf = new FPDI('P', 'mm', 'Legal'); // add a page $pdf->AddPage(); // set the sourcefile $pdf->setSourceFile('dtr/template/pds/page4.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, 1, 1, 210); // now write some text above the imported page $pdf->SetFont('Arial'); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(8, 14); $q = new Question(); $q->order_by('question_no'); $questions = $q->get_by_employee_id($employee_id); foreach ($questions as $question) { if ($question->question_no == 1) { if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 2) { $pdf->Ln(21); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 3) { $pdf->Ln(26); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 4) { $pdf->Ln(21); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 5) { $pdf->Ln(26); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 6) { $pdf->Ln(26); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 7) { $pdf->Ln(21); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 8) { $pdf->Ln(35); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 9) { $pdf->Ln(12); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } if ($question->question_no == 10) { $pdf->Ln(13); if ($question->answer == 1) { $setx = 138.5; } else { $setx = 164; } $pdf->SetX($setx); $pdf->Write(0, 'X'); } } $pdf->SetXY(8, 233); //$pdf->Write(0, 'X'); $r = new Reference(); $references = $r->get_by_employee_id($employee_id); foreach ($references as $reference) { $pdf->SetX(8); $pdf->Write(0, $reference->name); $pdf->SetX(72); $pdf->Write(0, $reference->address); $pdf->SetX(134); $pdf->Write(0, $reference->tel_no); $pdf->Ln(4); } // CTC NO $pdf->SetXY(15, 275); $pdf->Write(0, $reference->ctc_no); $pdf->Ln(13); $pdf->SetX(15); $pdf->Write(0, $reference->issue_at); $pdf->Ln(13); $pdf->SetX(15); $pdf->Write(0, $reference->issue_on); $pdf->SetX(90); $pdf->Write(0, date('F d, Y')); // Output $pdf->Output('dtr/template/pds/page4_' . $employee_id . '.pdf', 'F'); //header("location:".base_url()."resources/pdfs/archives/page4_".$employee_id.'.pdf'); $this->pds[] = 'dtr/template/pds/page4_' . $employee_id . '.pdf'; }