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 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); } }
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 schedule_retirement_pay($date_retired = '', $employee_id = '1') { $data = array(); $data['msg'] = ''; $this->load->library('fpdf'); if (!defined('FPDF_FONTPATH')) { define('FPDF_FONTPATH', $this->config->item('fonts_path')); } $this->load->library('fpdi'); // initiate FPDI $pdf = new FPDI('L', 'mm', 'Legal'); $pdf->SetAutoPageBreak(FALSE); // add a page $pdf->AddPage(); // set the sourcefile $pdf->setSourceFile('dtr/template/leave/schedule_retirement_pay.pdf'); // select the first page $tplIdx = $pdf->importPage(1); // use the page we imported $pdf->useTemplate($tplIdx); $e = new Employee_m(); $e->get_by_employee_id($employee_id); // set font, font style, font size. $pdf->SetFont('Times', '', 10); $pdf->SetTextColor(89, 89, 89); // set initial placement $pdf->SetXY(142, 20.5); $personal = new Personal_m(); $personal->where('employee_id', $e->id); $personal->get(1); $this->load->helper('date'); $o = new Office_m(); $o->get_by_office_id($e->office_id); $period = 'January 1, 2012 May 10, 2012'; $office_name = $o->office_name; $lgu_name = Setting::getField('lgu_name'); //var_dump($date_retired); $date_retired_diff = $date_retired; $date_birth = convert_long_date($personal->birth_date, TRUE); $first_day_of_service = convert_long_date($e->first_day_of_service); $date_retired = convert_long_date($date_retired, TRUE); $salary = $this->Salary_grade->get_monthly_salary($e->salary_grade, $e->step); //$pdf->SetX(114); $pdf->Write(0, $period); $pdf->Ln(10); $pdf->SetX(63); $pdf->Write(0, $office_name); $pdf->Ln(5); $pdf->SetX(63); $pdf->Write(0, $lgu_name); $pdf->SetFont('Times', 'B', 10); $pdf->Ln(21.5); $pdf->SetX(14); $pdf->Write(0, $e->fname . ' ' . substr($e->mname, 0, 1) . '. ' . $e->lname); $pdf->SetFont('Times', '', 10); $pdf->SetX(65); $pdf->Write(0, $date_birth); $pdf->SetX(88); $pdf->Write(0, $date_retired); $date1 = new DateTime("1970-7-01"); $date2 = new DateTime("2011-11-16"); $date1 = new DateTime($e->first_day_of_service); $date2 = new DateTime($date_retired_diff); $interval = $date1->diff($date2); //echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days "; if ($interval->y != 0) { $pdf->SetX(114); $pdf->Write(0, $interval->y . " years"); } if ($interval->m != 0) { $pdf->Ln(5); $pdf->SetX(114); $pdf->Write(0, $interval->m . " months"); } if ($interval->d != 0) { $pdf->Ln(5); $pdf->SetX(114); $pdf->Write(0, $interval->d . " days"); } // Salary $pdf->SetXY(145, 53); $pdf->Cell(20, 8, number_format($salary, 2), '', 0, 'C', FALSE); $total_leave = $this->Leave_card->get_total_leave_credits($employee_id); $vacation_leave = $total_leave['vacation']; $sick_leave = $total_leave['sick']; $total = $vacation_leave + $sick_leave; $terminal_leave = $salary * $total * 0.0478087; // vacation leave $pdf->SetXY(203, 58); $pdf->Cell(20, 8, number_format($vacation_leave, 3), '', 0, 'R', FALSE); // sick leave $pdf->SetXY(203, 63); $pdf->Cell(20, 8, number_format($sick_leave, 3), '', 0, 'R', FALSE); // total $pdf->SetXY(203, 68); $pdf->Cell(20, 8, number_format($total, 3), '', 0, 'R', FALSE); // terminal leave $pdf->SetX(274); $pdf->Cell(20, 8, number_format($terminal_leave, 2), '', 0, 'R', FALSE); $pdf->SetFont('Times', 'B', 10); // grand total leave $pdf->SetXY(203, 119); $pdf->Cell(20, 8, number_format($total, 3), '', 0, 'R', FALSE); // total terminal amount $pdf->SetX(274); $pdf->Cell(20, 8, number_format($terminal_leave, 2), '', 0, 'R', FALSE); // Signatories $pdf->Ln(35); $pdf->SetX(13); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_prepared'), '', 0, 'C', FALSE); // date $pdf->SetFont('Times', '', 10); $pdf->SetX(76); $pdf->Cell(50, 8, date('F d, Y'), '', 0, 'C', FALSE); $pdf->SetFont('Times', 'B', 10); $pdf->SetX(147); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_approved'), '', 0, 'C', FALSE); $pdf->SetFont('Times', '', 10); $pdf->Ln(5); $pdf->SetX(13); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_prepared_position'), '', 0, 'C', FALSE); $pdf->SetX(146); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_approved_position'), '', 0, 'C', FALSE); $pdf->SetFont('Times', 'B', 10); $pdf->Ln(25); $pdf->SetX(13); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_certified'), '', 0, 'C', FALSE); $pdf->SetX(88); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_attested'), '', 0, 'C', FALSE); $pdf->SetX(147); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_availability'), '', 0, 'C', FALSE); $pdf->SetX(223); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_noted'), '', 0, 'C', FALSE); $pdf->SetFont('Times', '', 10); $pdf->Ln(5); $pdf->SetX(13); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_certified_position'), '', 0, 'C', FALSE); $pdf->SetX(88); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_attested_position'), '', 0, 'C', FALSE); $pdf->SetX(147); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_availability_position'), '', 0, 'C', FALSE); $pdf->SetX(223); $pdf->Cell(50, 8, Setting::getField('retirement_signatory_noted_position'), '', 0, 'C', FALSE); header('Cache-Control: maxage=3600'); //Adjust maxage appropriately header('Pragma: public'); $pdf->Output('dtr/reports/schedule_retirement_pay' . $employee_id . '.pdf', 'F'); // index 'L' for landscape $this->pages['L'] = 'dtr/reports/schedule_retirement_pay' . $employee_id . '.pdf'; }
private function SetHTMLTextColor($htmlHex) { parent::SetTextColor(hexdec(substr($htmlHex, 0, 2)), hexdec(substr($htmlHex, 2, 2)), hexdec(substr($htmlHex, 4, 2))); }
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 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'; }
require 'fpdf.php'; require 'fpdi.php'; header('Content-Type: text/pdf; charset=UTF-8'); $dni = $_POST["tbDni"]; $nombre = $_POST["tbNombre"]; $fecha = (new DateTime())->format("dd/mm/YY"); $pdf = new FPDI(); $pdf->AddPage(); $pdf->setSourceFile("diploma-plantilla.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, 0, 0, 0, 0, true); $pdf->SetFont('Helvetica', "", 12); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(30, 80); $pdf->write(0, utf8_decode("La Universidad de La Rioja otorga el siguiente diploma a")); $pdf->SetFont('Helvetica', "", 20); $pdf->SetTextColor(255, 10, 10); $pdf->SetXY(30, 90); $pdf->write(0, utf8_decode(utf8_encode($nombre))); $pdf->SetFont('Helvetica', "", 12); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(30, 100); $pdf->write(0, utf8_decode("Con dni: " . $dni . " ha superado con éxito el programa formativo,")); $pdf->SetFont('Helvetica', "", 25); $pdf->SetTextColor(255, 30, 30); $pdf->SetXY(30, 110); $pdf->write(0, utf8_decode("CURSO DE MANIPULACIÓN DE PDF")); $pdf->SetFont('Helvetica', "", 12);
$pdf->Ln(6); $pdf->write(15, ' ' . $clie['email']); $products = $facadeProyecto->obtenerDatoProductoProyecto($_GET['proNum']); $pdf->Ln(15); $pdf->SetFontSize(15); $pdf->SetFont('Arial', 'B'); $pdf->write(15, ' Productos Solicitados:'); $pdf->SetFontSize(11); if (!empty($products)) { $pdf->Ln(12); $pdf->write(15, ' ' . utf8_decode('Código ') . 'Nombre Producto ' . 'Cantidad ' . '% Ganancia ' . 'IVA '); $j = 200; foreach ($products as $productos) { $pdf->Ln(8); if ($productos['cantidadProductos'] != 0) { $pdf->SetTextColor(97, 97, 97); $pdf->SetXY(35, $j); $pdf->Write(0, $productos['idProductos']); $pdf->SetXY(53, $j); $pdf->Write(0, $productos['nombreProducto']); $pdf->SetXY(91, $j); $pdf->Write(0, $productos['cantidadProductos'] . '/Uni.'); $pdf->SetXY(115, $j); $pdf->Write(0, $productos['ganancia'] . '%'); $pdf->SetXY(141, $j); $pdf->Write(0, $productos['iva']); $j = $j + 6; } } } //enviamos cabezales http para no tener problemas
function FlyerRendering($inputFile, $outputPostfix, $anschnitt) { /*------------------------------------------------------------------------------------ * Bitte tragt hier eure lokalen Freifunk Daten ein. *------------------------------------------------------------------------------------ * * Hinweiss Community-Logo: * Moegliche Format sind GIF, JPG und PNG. * * Laenge des Community Namen: * Falls der Community-Name zu lang ist und es zu einem Zeilenumbruch kommt, * dann sollte $communityNameFontSize verkleiner werden * -------------------------------------------------------------------------------------*/ // Community Name fuer Hauptseite $communityNameText = "Freifunk Duckburg"; $communityNameFontSize = 48.0; //in pt $communityNamePositionOffsetX = 0.0; // +/- in mm $communityNamePositionOffsetY = 0.0; // +/- in mm // Logo auf Kontaktseite $kontaktLogoDateiName = "logo-template.png"; $kontaktLogoWidth = 66.25; //in mm // Muss kleiner 98.0 mm sein! Hier bitte die gewuenschte Breite des Logos auf dem Flyer eintragen. $kontaktLogoPositionY = 47.0; //in mm // Die Hoeheneinstellung ist etwas frickelig. Es klappt aber :-) // Texte fuer Seite mit Kontaktdaten $kontaktTitelText = "Kontakt"; $kontaktInfoTexte = [["Webseite", "http://ffdb.freifunk.net"], ["Mail", "*****@*****.**"], ["Mailingliste", "*****@*****.**"], ["Twitter", "@FreiFunkDB"], ["Treffen", "Jeden zweiten Montag"], ["", "Und wo? Siehe unsere Webseite"], ["", ""], ["", ""]]; // Text Fusszeile $kontaktFusszeileText = "Freifunk Duckburg e.V."; /*----------------------------------------------------------------------------------- * * Ab hier sollte nichts mehr geander werden! * ------------------------------------------------------------------------------------*/ // Breite der einzelnen Seiten $wRechts = 99.0; //mm $wMitte = 98.0; //mm $wLinks = 97.0; //mm // Community Name $communityNamePositionX = $wLinks + $wMitte + $communityNamePositionOffsetX; //mm $communityNamePositionY = 12.2 + $communityNamePositionOffsetY; //mm // Kontakt Titel $kontaktTitelPositionX = $wLinks + 3.975; //mm $kontaktTitelPositionY = 10.425; //mm $kontaktTitelFontSize = 15.0; //pt // Kontakt Info $kontaktInfoTextPositionX = $kontaktTitelPositionX + 25.0; //mm $kontaktInfoPositionY = $kontaktTitelPositionY + 7.0; //mm $kontaktInfoZeilenOffsetY = 4.7; //mm $kontaktInfoFontSize = 10.9; //pt // Kontakt Logo $kontaktLogoPositionX = $wLinks + $wMitte / 2 - $kontaktLogoWidth / 2; // Kontakt Footer $kontaktFooterPositionX = $wLinks; //mm $kontaktFooterPositionY = 95.40000000000001; //mm $kontaktFooterWidth = $wMitte; //mm $kontaktFooterFontSize = 10.9; //pt echo "\n"; // Output-Dasteiname zusammenbauen $outputFile = $outputPostfix . "-" . $inputFile; // initiate FPDI $pdf = new FPDI(); echo "Input: {$inputFile}\n"; $pageCount = $pdf->setSourceFile($inputFile); // Importiere Vorder- und Rueckseite $Vorderseite = $pdf->ImportPage(1); $Rueckseite = $pdf->ImportPage(2); // Seitenabmessungen holen $size = $pdf->getTemplateSize($Vorderseite); $dokumentBreite = round($size['w'], 2); $dokumentHoehe = round($size['h'], 2); echo "Dokumenten Breite: {$dokumentBreite} mm\n"; echo "Dokumenten Hoehe: {$dokumentHoehe} mm\n"; echo "Anschnitt: {$anschnitt} mm\n"; // Vorderseite uebernehmen // Anfang eines bloeden Hacks wegen des FooterZeilen-Textes. // Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist. // Keine Ahnung warum! $pdf->AddPage('L'); $tplVorderseite = $pdf->importPage(1); $pdf->useTemplate($tplVorderseite); //Margin ist wegen der Rand-Platzierung des Community Names wichtig. $pdf->SetMargins(0, 0, 0); // erstmal alle Fonts laden echo "Lade Fonts...\n"; $pdf->AddFont('lato-bold'); $pdf->AddFont('lato-regular'); $pdf->AddFont('alternategothic'); // Rendern Titel Text echo "Verarbeite Titel Text...\n"; $pdf->SetFont('lato-bold'); $pdf->SetFontSize($kontaktTitelFontSize); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $kontaktTitelText)); // Rendern Info Text echo "Verarbeite Info Text...\n"; $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetFontSize($kontaktInfoFontSize); foreach ($kontaktInfoTexte as $a) { $pdf->SetFont('lato-bold'); $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0])); $pdf->SetFont('lato-regular'); $pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1])); $kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY; } // Rendern Community Logo echo "Verarbeite Logo...\n"; $pdf->Image($kontaktLogoDateiName, $kontaktLogoPositionX + $anschnitt, $kontaktLogoPositionY + $anschnitt, $kontaktLogoWidth, 0); // Rendern Fusszeilen Text echo "Verarbeite Fusszeile...\n"; $pdf->SetFont('lato-regular'); $pdf->SetFontSize($kontaktFooterFontSize); $pdf->SetTextColor(255, 255, 255); //weiss $pdf->SetXY($kontaktFooterPositionX + $anschnitt, $kontaktFooterPositionY + $anschnitt); $pdf->Cell($kontaktFooterWidth, 0, iconv('UTF-8', 'windows-1252', $kontaktFusszeileText), 0, 0, 'C'); // Rendern Community Name echo "Verarbeite Community Name...\n"; $pdf->SetFont('alternategothic'); $pdf->SetFontSize($communityNameFontSize); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($communityNamePositionX + $anschnitt, $communityNamePositionY + $anschnitt); $pdf->MultiCell($wRechts, 10, iconv('UTF-8', 'windows-1252', $communityNameText), 0, 'C'); // Das war's mit dem Editieren // Original PDF Rueckseit uebernehmen $pdf->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf->importPage(2); $pdf->useTemplate($tplRueckseite); // und erstmal abspeichern echo "Zwischenspeichern...\n"; $pdf->Output($outputFile); // Hier geht jetzt der Hack wegen der Footerzeile weiter // Die gerade abgespeicherte Datei wird erneut eingelesen // um dann im Seiten-Format der Ursprungsdatei erneut abgespeichert zu werden. // Is' doof, muss aber sein $pdf_2 = new FPDI(); echo "Erneut laden...\n"; $pageCount = $pdf_2->setSourceFile($outputFile); echo "Feinschliff...\n"; $Vorderseite_2 = $pdf_2->ImportPage(1); $Rueckseite_2 = $pdf_2->ImportPage(2); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplForderseite = $pdf_2->importPage(1); $pdf_2->useTemplate($tplForderseite); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf_2->importPage(2); $pdf_2->useTemplate($tplRueckseite); echo "Output: {$outputFile}\n"; $pdf_2->Output($outputFile); unset($pdf); unset($pdf_2); }
public function generatepdfAction(command $commande) { $request = $this->get('request'); $tools = $this->get('tools.utils'); $session = $request->getSession(); if ($session->has('tpl')) { $tpl = $commande->getToprint(); $pdffile = ""; foreach ($tpl as $key => $elemnt) { foreach ($elemnt as $val) { $prod = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($val['id']); $template = $prod->getTpl(); $tplpdf = str_replace("../", "", $template->getPdf()); $pdffile = $this->get('kernel')->getRootDir() . '/../web/' . $tplpdf; } } $custom_layout = array(85, 55); $orientation = 'L'; $pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false); $pdf->setPageOrientation($orientation); $pdf->SetMargins(0, 0, 0); $pdf->SetAutoPageBreak(true, 0); $pdf->setFontSubsetting(false); $pdf->AddPage($orientation); // echo "<pre>";print_r($pdf->getMargins());exit; $pdf->setSourceFile($pdffile); $_tplIdx = $pdf->importPage(1); $size = $pdf->useTemplate($_tplIdx, 0, 0, 85, 55, true); $idd = ""; $i = 0; $oldx = 0; $oldy = 0; foreach ($elemnt as $value) { //if($i==0) if ($idd != $value['id'] && $value['value'] != "") { $pdf->SetPageMark(); if (substr($value['value'], 0, 4) != "/tmp") { //$tools->dump($value); $align = strtoupper(substr($value['align'], 0, 1)); $color = $this->hex2rgb($value['color']); $pdf->SetTextColor($color[0], $color[1], $color[2]); $param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']); $y2 = $param->getX1() / 5; $x1 = $param->getY1() / 5; //$x1 = 10;$y2 = 8; $w = $param->getX2() / 5; $h = $param->getY2() / 5; $oldx = $x1; $oldy = $y2; $pdf->SetX($x1, false); $pdf->SetY($y2, false); //$pdf->SetXY($x1, $y2,true); $pdf->SetFont(null, '', $param->getSize() * 0.6); //$param->getPolice() // echo $opt->getFontsize()."\n"; $pdf->Cell($w, $h, $value["value"], 0, 0, $align); } else { $param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']); $img = $this->getParameter('base_url') . $value['value']; $pdf->Image($img, $param->getX1() / 4.5, $param->getY1() / 4.55, $param->getX2() / 4.55, $param->getY2() / 4.5, '', '', '', true); } } $idd = $value['id']; $i++; } //$pdf->Cell(0, $size['h'], 'TCPDF and FPDI'); // echo $template->getId(); $pdf->Output($this->get('kernel')->getRootDir() . '/../web/pdf.pdf'); } return new Response(""); }
// for changes in this section. //==================================================================== $pdf = new FPDI(); $pdf->AddPage(); // import the template PFD $pdf->setSourceFile($filename); // select the first page $tplIdx = $pdf->importPage(1); // use the page we imported $pdf->useTemplate($tplIdx); //==================================================================== // Write to the document //==================================================================== // set font, font style, font size. $pdf->SetFont('Arial', '', 6); $pdf->SetTextColor(0, 51, 102); // set initial placement $pdf->SetXY(27, 15); // line break //$pdf->Ln(5); // go to 25 X (indent) $pdf->SetX(27); // write $pdf->SetFont('Arial', '', 10); $pdf->Write(0, utf8_decode($ObtenerCabeceraFacturacion[0]['nombreCliente'])); // move to next line $pdf->Ln(5); $pdf->SetFont('Arial', '', 7); // The following section is basically a repetition of the previous for inserting more text. // repeat for more text: $pdf->SetX(27);
function preview($employee_id) { $this->load->helper('settings'); $this->load->library('fpdf'); //define('FPDF_FONTPATH',$this->config->item('fonts_path')); $this->load->library('fpdi'); //$pi = new Personal(); //$pi->get_by_employee_id( $employee_id ); //print_r($personal_info); // initiate FPDI $pdf = new FPDI('P', 'mm', 'Letter'); // add a page $pdf->AddPage(); // set the sourcefile //$pdf->setSourceFile('dtr/template/service_record/service_record.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(15, 60); $pdf->SetFont('Arial', '', 16); $pdf->Cell(0, 3, "Employee's Service Record", '', 1, 'C', false); $pdf->Ln(4); $e = new Employee_m(); $e->get_by_id($employee_id); $pdf->SetFont('Arial', '', 12); $pdf->Cell(0, 8, "Employee No.:" . $e->employee_id, '', 1, 'L', false); $pdf->Ln(2); $pdf->SetFont('Arial', '', 12); $pdf->Cell(0, 8, "Employee Name:" . $e->lname . ', ' . $e->fname . ' ' . $e->mname, '', 1, 'L', false); $pdf->Ln(4); $pdf->Cell(0, 8, "Date From Date To Position Department Movement Status Status", '1', 1, 'L', false); $pdf->Ln(4); $work = new Work(); $work->where('govt_service', '1'); $work->order_by('inclusive_date_from', 'DESC'); $works = $work->get_by_employee_id($employee_id); $i = 1; $this->load->helper('text'); foreach ($works as $work) { $pdf->SetFont('Arial', '', 8); $pdf->SetX(10); list($year, $month, $day) = explode('-', $work->inclusive_date_from); $inclusive_date_from = $month . '/' . $day . '/' . $year; $pdf->Write(0, $inclusive_date_from); list($year, $month, $day) = explode('-', $work->inclusive_date_to); $inclusive_date_to = $month . '/' . $day . '/' . $year; if ($work->inclusive_date_to == 'Present') { $inclusive_date_to = 'Present'; } $pdf->SetX(29); $pdf->Write(0, $inclusive_date_to); $pdf->SetFont('Arial', '', 8); $pdf->SetX(50); $pdf->Write(0, str_replace('…', '..', character_limiter($work->position, 35))); $pdf->SetX(100); //$pdf->Write(0, $work->company); $pdf->Write(0, str_replace('…', '..', character_limiter($work->company, 35))); //$pdf->SetFont('Arial', '', 12); $pdf->SetX(160); $pdf->Write(0, $work->movement); //$pdf->SetX(150); //$pdf->Write(0, $work->salary_grade); $pdf->SetFont('Arial', '', 8); $pdf->SetX(185); $pdf->Write(0, $work->status); $work->govt_service = $work->govt_service == 1 ? 'Yes' : 'No'; $pdf->SetX(190); //$pdf->Write(0, $work->govt_service); $pdf->SetFont('Arial', '', 12); if ($i == 6 || $i == 10 || $i == 13 || $i == 16 || $i == 19 || $i == 22) { $pdf->Ln(8); } else { $pdf->Ln(7); } $i++; } $pdf->Cell(0, 8, "--------------------------------------------------------- Nothing Follows ---------------------------------------------------------", '', 1, 'C', false); // Signatories $pdf->Ln(15); $pdf->SetX(20); $pdf->Cell(90, 5, "PREPARED BY:", '0', 0, 'C', false); $pdf->Cell(90, 5, "CERTIFIED CORRECT:", '0', 1, 'C', false); $pdf->Ln(10); $sr_prepared = Setting::getField('sr_prepared'); $sr_prepared_position = Setting::getField('sr_prepared_position'); $sr_certified = Setting::getField('sr_certified'); $sr_certified_position = Setting::getField('sr_certified_position'); $pdf->SetX(20); $pdf->Cell(90, 5, $sr_prepared, '0', 0, 'C', false); //4th param border $pdf->Cell(90, 5, $sr_certified, '0', 1, 'C', false); $pdf->SetX(20); $pdf->Cell(90, 5, $sr_prepared_position, '0', 0, 'C', false); $pdf->Cell(90, 5, $sr_certified_position, '0', 1, 'C', false); // Output $pdf->Output('dtr/template/service_record/archives/service_record_' . $employee_id . '.pdf', 'I'); }
public function test() { // $rgb_arr = sscanf('rgb(243, 243, 243)', "rgb(%d, %d, %d)"); // print_r($this->rgbToCmyk($rgb_arr[0], $rgb_arr[1], $rgb_arr[2])); // exit(); // $img = new Imagick('test.jpg'); $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1); $img->setresolution(300, 300); $img->setimageformat('pdf'); $img->writeimage('test.pdf'); include_once APPPATH . 'libraries/tcpdf/tcpdf.php'; include_once APPPATH . 'libraries/tcpdf/fpdi.php'; // создаём лист $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false); $pdf->AddPage('L'); // загрузим ранее сохранённый шаблон $pdf->setSourceFile('test.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); $pdf->Image('qwe.png', 30, 30, 20, '', '', '', '', false, 300); $pdf->SetTextColor(0, 0, 0, 100); $pdf->SetFont('helvetica', 'BI', 10, '', 'false'); $pdf->Text(12, 9, 'Black CMYK'); $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/uploads/fynal.pdf', 'F'); $im = new Imagick(); $im->setResolution(300, 300); $im->readimage('uploads/fynal.pdf[0]'); $im->setImageFormat('jpeg'); $im->resizeimage(538, 360, Imagick::FILTER_LANCZOS, 1); $im->writeImage('uploads/fynal.jpg'); $im->clear(); $im->destroy(); // include_once APPPATH . 'libraries/drawer.php'; // // $drawer = new Drawer(); // $drawer->init(); // $drawer->setLayout(); // $drawer->setBackground('test.jpg'); // $drawer->drawImage('test.jpg', 10, 10, 30); // $drawer->drawText('Maxim', 10, 10, 'TimesNewRoman', 20, 'rgb(77, 77, 77)'); // $drawer->savePdf($_SERVER['DOCUMENT_ROOT'] . '/1.pdf'); // $drawer->makePreview($_SERVER['DOCUMENT_ROOT'] . '/1.pdf', $_SERVER['DOCUMENT_ROOT'] . '/1.jpg'); }
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; }
public function download_tag() { $r1 = Input::has('r1') ? Input::get('r1') : 'Mr Sam Sample'; $r2 = Input::has('r2') ? Input::get('r2') : 'Sample Street'; $r3 = Input::has('r3') ? Input::get('r3') : 'Sampletown VIC 3000'; $r4 = Input::has('r4') ? Input::get('r4') : 'phone +61 414 141 414'; if ($user = Auth::user()) { $member = Member::where('user_id', '=', $user->id)->first(); $r1 = $member->firstname . ' ' . $member->lastname; $r2 = $member->address; $r3 = $member->suburb . ' ' . $member->state . ' ' . $member->postcode; $r4 = 'phone ' . $member->phone; } $pdf = new FPDI('L'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); $pdf->setSourceFile(realpath(dirname(__FILE__)) . '/../../public/assets/pdf/luggage_tags.pdf'); $pdf->SetTextColor(0, 0, 0); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx); $pdf->SetFont('museosansrounded1000'); $pdf->SetXY(121, 40); $pdf->Write(20, $r1); $pdf->SetXY(121, 45); $pdf->Write(20, $r2); $pdf->SetXY(121, 50); $pdf->Write(20, $r3); $pdf->SetXY(121, 55); $pdf->Write(20, $r4); $pdf->Output('luggage-tag.pdf'); }
public function executeBatchPrintBadge(sfWebRequest $request) { $ids = $request->getParameter('ids'); // initiate FPDI $pdf = new FPDI('P', 'pt'); // set the sourcefile $pdf->setSourceFile(sfConfig::get('sf_upload_dir') . '/badges/ID_new.pdf'); foreach ($ids as $id) { $this->employee = EmployeePeer::retrieveByPk($id); // import page 1 $tplIdx = $pdf->importPage(1); // add a new page based on size of the badge $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage('P', array($s['w'], $s['h'])); $pdf->useTemplate($tplIdx); $pdf->setMargins(0, 0, 0, 0); $pdf->SetAutoPageBreak(false); if ($this->employee->getPicture()) { $pdf->Image(sfConfig::get('sf_upload_dir') . '/' . sfConfig::get('app_employee_images_dir') . '/' . $this->employee->getPicture(), 29.5, 25.5, 60.3, 74.3); } else { $pdf->Image(sfConfig::get('sf_upload_dir') . '/badges/picture_missing.jpg', 29.5, 25.5, 60.3, 74.3); } // now write some text above the imported page $pdf->SetFont('freesans', 'B', 12); $pdf->SetTextColor(82, 78, 134); $pdf->SetXY(22, 110); $pdf->Cell(0, 12, $this->employee->getFullName()); $pdf->Ln(); $pdf->SetX(22); $pdf->SetFont('freesans', 'BI', 10); $pdf->Cell(0, 14, $this->employee->getJob()); $pdf->SetDisplayMode('real'); } return $pdf->Output('newpdf.pdf', 'D'); }
$fullName = $_REQUEST['suname'] . ' ' . $_REQUEST['name'] . ' ' . $_REQUEST['midlname']; $currentDate = currentDate(); $cuponNum = generateCuponNumber(); sendEmail($cuponNum, $currentDate, $fullName); $pdf = new FPDI(); $pdf->setSourceFile($file); $tpl = $pdf->importPage(1); $size = $pdf->getTemplateSize($tpl); $orientation = $size['h'] > $size['w'] ? 'P' : 'L'; $pdf->AddPage($orientation); $pdf->useTemplate($tpl, null, null, $size['w'], $size['h'], true); $pdf->AddFont('AgencyFBCyrillic', '', 'agenfbcyr.php'); $pdf->AddFont('GoodVibesPro', '', 'good_vibes_pro_regular.php'); $pdf->SetXY(41.628, 91.017); $pdf->SetFont('GoodVibesPro', '', 40); $pdf->SetTextColor(184, 153, 106); $pdf->Cell(212.019, 20.814, iconv('UTF-8', 'CP1251', $fullName), 0, 2, 'C'); $pdf->SetXY(56.797, 160.396); $pdf->SetFont('AgencyFBCyrillic', '', 21); $pdf->SetTextColor(32, 22, 0); $pdf->Cell(44.097, 7.173, iconv('UTF-8', 'CP1251', $currentDate), 0, 2, 'C'); $pdf->SetXY(194.263, 160.396); $pdf->SetFont('AgencyFBCyrillic', '', 21); $pdf->SetTextColor(32, 22, 0); $pdf->Cell(44.332, 7.173, iconv('UTF-8', 'CP1251', $cuponNum), 0, 2, 'C'); $pdf->Output('Your_Cupon.pdf', 'D'); } function currentDate() { $date = explode('.', date('j.n.Y')); switch ($date[1]) {
require_once 'fpdf.php'; require_once 'pdf/fpdi.php'; // initiate FPDI $pdf = new FPDI(); // add a page $pdf->AddPage(); // set the sourcefile $pdf->setSourceFile('Guía de Traslado.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, 0, 0, null); // now write some text above the imported page $pdf->SetFont('Arial', '', 10); $pdf->SetTextColor(255, 0, 0); $pdf->SetXY(40, 31); $pdf->Write(0, "Establecimiento"); $pdf->SetXY(40, 35); $pdf->Write(0, "HEYMAN GRACIELA BEATRIZ"); $pdf->SetXY(40, 39); $pdf->Write(0, "HEYMAN GRACIELA BEATRIZ"); $pdf->SetXY(40, 43); $pdf->Write(0, "27059421862"); $pdf->SetXY(40, 47); $pdf->Write(0, "CHA.72 PC.12 PARQUE INDUSTRIAL"); $pdf->SetXY(40, 51); $pdf->Write(0, "General Guemes"); $pdf->SetXY(40, 55); $pdf->Write(0, "Chaco"); $pdf->SetFont('Arial', '', 8);
if ($_REQUEST["accion"] == "i") $pdf = new PDF_AutoPrint(); else $pdf = new FPDI(); $pdf->setSourceFile(DATA_AVISO_OBRA_PATH.$_REQUEST["filename"].".".$_REQUEST["extension"]); $pdf->AddPage(); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx); $_REQUEST["x"] = $_REQUEST["x"] * 0.686; $_REQUEST["y"] = $_REQUEST["y"] * 0.728; if ($_REQUEST["tipoSello"] == "n") { $pdf->SetFont("Arial", "B", 14); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY($_REQUEST["x"] + 8, $_REQUEST["y"] + 18); $pdf->Cell(0, 0, "NO CORRESPONDE PRESENTACIÓN"); $pdf->SetXY($_REQUEST["x"] + 11, $_REQUEST["y"] + 24); $pdf->Cell(0, 0, "POR ACTIVIDAD DESARROLLADA"); } else { $pdf->SetFont("Arial", "B", 16); switch ($_REQUEST["tipoSello"]) { case "e": $pdf->SetDrawColor(0, 0, 196); $pdf->SetTextColor(0, 0, 196); break; case "h": $pdf->SetDrawColor(196, 0, 0);
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; }
function write_instruction($rec_ind, $q, $data) { // $ind = recipe index, $q = quote array, $data = recipe data array // Dynamic Data $bul = html_entity_decode("•", ENT_HTML401, "cp1252"); $deg = html_entity_decode("°", ENT_HTML401, "cp1252"); $recipe = $data[$rec_ind][0]; $style = $data[$rec_ind][1]; $og = $data[$rec_ind][2]; $fg = $data[$rec_ind][3]; $abv = $data[$rec_ind][4] . "%"; //$hop1 = $bul . " " . $data[$rec_ind][5]; if (empty($data[$rec_ind][5])) { $hop1 = ""; } else { $hop1 = $bul . " " . $data[$rec_ind][5]; } if (empty($data[$rec_ind][6])) { $hop2 = ""; } else { $hop2 = $bul . " " . $data[$rec_ind][6]; } if (empty($data[$rec_ind][7])) { $hop3 = ""; } else { $hop3 = $bul . " " . $data[$rec_ind][7]; } if (empty($data[$rec_ind][8])) { $hop4 = ""; } else { $hop4 = $bul . " " . $data[$rec_ind][8]; } if (empty($data[$rec_ind][9])) { $hop5 = ""; } else { $hop5 = $bul . " " . $data[$rec_ind][9]; } if (empty($data[$rec_ind][10])) { $hop6 = ""; } else { $hop6 = $bul . " " . $data[$rec_ind][10]; } if (empty($data[$rec_ind][11])) { $sp_inst = "No special instructions needed. Instead, we have included a quote about beer: \n" . $q[rand(0, 12)]; } else { $sp_inst = $data[$rec_ind][11]; } if (empty($data[$rec_ind][12])) { $ing1 = ""; } else { $ing1 = $bul . " " . $data[$rec_ind][12]; } if (empty($data[$rec_ind][13])) { $ing2 = ""; } else { $ing2 = $bul . " " . $data[$rec_ind][13]; } if (empty($data[$rec_ind][14])) { $ing3 = ""; } else { $ing3 = $bul . " " . $data[$rec_ind][14]; } if (empty($data[$rec_ind][15])) { $ing4 = ""; } else { $ing4 = $bul . " " . $data[$rec_ind][15]; } if (empty($data[$rec_ind][16])) { $ing5 = ""; } else { $ing5 = $bul . " " . $data[$rec_ind][16]; } if (empty($data[$rec_ind][17])) { $ing6 = ""; } else { $ing6 = $bul . " " . $data[$rec_ind][17]; } if (empty($data[$rec_ind][18])) { $ing7 = ""; } else { $ing7 = $bul . " " . $data[$rec_ind][18]; } if (empty($data[$rec_ind][19])) { $ing8 = ""; } else { $ing8 = $bul . " " . $data[$rec_ind][19]; } if (empty($data[$rec_ind][20])) { $ing9 = ""; } else { $ing9 = $bul . " " . $data[$rec_ind][20]; } if (empty($data[$rec_ind][21])) { $ing10 = ""; } else { $ing10 = $bul . " " . $data[$rec_ind][21]; } if (empty($data[$rec_ind][22])) { $ing11 = ""; } else { $ing11 = $bul . " " . $data[$rec_ind][22]; } if (empty($data[$rec_ind][23])) { $ing12 = ""; } else { $ing12 = $bul . " " . $data[$rec_ind][23]; } if (empty($data[$rec_ind][24])) { $ing13 = ""; } else { $ing13 = $bul . " " . $data[$rec_ind][24]; } if (empty($data[$rec_ind][25])) { $ing14 = ""; } else { $ing14 = $bul . " " . $data[$rec_ind][25]; } if (empty($data[$rec_ind][26])) { $ing15 = ""; } else { $ing15 = $bul . " " . $data[$rec_ind][26]; } if (empty($data[$rec_ind][27])) { $ing16 = ""; } else { $ing16 = $bul . " " . $data[$rec_ind][27]; } if (empty($data[$rec_ind][28])) { $ing17 = ""; } else { $ing17 = $bul . " " . $data[$rec_ind][28]; } if (empty($data[$rec_ind][29])) { $ing18 = ""; } else { $ing18 = $bul . " " . $data[$rec_ind][29]; } // Initiate FPDI & FPDF $pdf = new FPDI(); $pdf->setSourceFile("extract_template.pdf"); // Create page 1 & Read Template Page 1 $pdf->AddPage('P', 'Letter'); $tmp = $pdf->importPage(1); $pdf->useTemplate($tmp, 0, 0); // Declare Fonts $pdf->AddFont('Kenyancoffee', '', 'Kenyancoffeerg.php'); $pdf->AddFont('Roboto', '', 'Roboto-Regular.php'); $pdf->AddFont('Roboto', 'L', 'Roboto-Light.php'); $pdf->AddFont('Roboto', 'B', 'Roboto-Bold.php'); // Write Dynamic Data - Header $pdf->SetFont('Kenyancoffee', '', 23); $pdf->SetTextColor(229, 80, 84); $pdf->SetXY(57.3, 19); $pdf->Cell(0, 0, $recipe); $pdf->SetFont('Roboto', 'L', 9.9); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(57.3, 25.5); $pdf->Cell(0, 0, $style); $pdf->SetFont('Roboto', 'L', 9.9); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(65.2, 36.2); $pdf->Cell(0, 0, $og); $pdf->SetFont('Roboto', 'L', 9.9); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(85.2, 36.2); $pdf->Cell(0, 0, $fg); $pdf->SetFont('Roboto', 'L', 9.9); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(108.5, 36.2); $pdf->Cell(0, 0, $abv); // Write Dynamic Data - Ingredients $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 156.5); $pdf->Cell(0, 0, $ing1); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 161.5); $pdf->Cell(0, 0, $ing2); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 166.5); $pdf->Cell(0, 0, $ing3); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 171.5); $pdf->Cell(0, 0, $ing4); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 176.5); $pdf->Cell(0, 0, $ing5); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 181.5); $pdf->Cell(0, 0, $ing6); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 186.5); $pdf->Cell(0, 0, $ing7); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 191.5); $pdf->Cell(0, 0, $ing8); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 196.5); $pdf->Cell(0, 0, $ing9); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 201.5); $pdf->Cell(0, 0, $ing10); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 206.5); $pdf->Cell(0, 0, $ing11); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 211.5); $pdf->Cell(0, 0, $ing12); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 216.5); $pdf->Cell(0, 0, $ing13); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 221.5); $pdf->Cell(0, 0, $ing14); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 226.5); $pdf->Cell(0, 0, $ing15); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 231.5); $pdf->Cell(0, 0, $ing16); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 236.5); $pdf->Cell(0, 0, $ing17); $pdf->SetFont('Roboto', 'B', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(5.3, 241.5); $pdf->Cell(0, 0, $ing18); // Write Dynamic Data - Hop Schedule $pdf->SetFont('Roboto', '', 7.5); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(114, 171); $pdf->Cell(0, 0, $hop1); $pdf->SetFont('Roboto', '', 7.5); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(114, 174.2); $pdf->Cell(0, 0, $hop2); $pdf->SetFont('Roboto', '', 7.5); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(114, 177.4); $pdf->Cell(0, 0, $hop3); $pdf->SetFont('Roboto', '', 7.5); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(114, 180.6); $pdf->Cell(0, 0, $hop4); $pdf->SetFont('Roboto', '', 7.5); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(114, 183.8); $pdf->Cell(0, 0, $hop5); $pdf->SetFont('Roboto', '', 7.5); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(114, 187); $pdf->Cell(0, 0, $hop6); // Create page 2 & Read Template Page 2 $pdf->AddPage('P', 'Letter'); $tmp = $pdf->importPage(2); $pdf->useTemplate($tmp, 0, 0); // Write Dynamic Data - Special Instructions $pdf->SetFont('Roboto', '', 7.5); $pdf->SetTextColor(255, 255, 255); $pdf->SetXY(11, 13); $pdf->MultiCell(165, 3, utf8_decode($sp_inst)); $shortname = str_replace(' ', '', $recipe); $filename = "C:/Users/tyler/Google Drive/MonsterBrew/Product/Recipe Kits/Instructions/Instructions - Extract/EX_INS_" . $shortname . ".pdf"; $pdf->Output($filename, 'F'); }
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'; }
function preview($rows, $report_name = '') { $html = ' <table width="100%" border="0"> <tr> <td colspan="3" align="center">' . $report_name . '</td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> <table width="100%" border="1"> <tbody><tr> <td width="10%"><strong>Employee ID</strong></td> <td width="9%"><strong>Name</strong></td> <td width="4%"><strong>Sex</strong></td> <td width="10%"><strong>Position/<br /> Designation</strong></td> <td width="13%"><strong>Office / Department</strong></td> <td width="11%"><strong>Employment Status</strong></td> <td width="6%"><strong>Salary Grade</strong></td> <td width="9%"><strong>Eligibility</strong></td> <td width="11%"><strong>Education</strong></td> <td width="8%"><strong>Birthday</strong></td> <td width="9%"><strong>Address</strong></td></tr>'; $office = new Orm_office(); foreach ($rows as $row) { $office->get_by_office_id($row->office_id); $type_employment = $this->options->type_employment(); $birth_date = $row->birth_date; if ($row->birth_date == '0000-00-00') { $birth_date = ''; } $html .= ' <tr> <td>' . $row->id . '</td> <td>' . $row->lname . ',' . $row->fname . ' ' . $row->mname . '</td> <td>' . $row->sex . '</td> <td>' . $row->position . '</td> <td>' . $office->office_name . '</td> <td>' . $type_employment[$row->permanent] . '</td> <td>' . $row->salary_grade . '-' . $row->step . '</td> <td>' . $row->eligibility . '</td> <td>' . $row->education . '</td> <td>' . $birth_date . '</td> <td>' . $row->res_address . '</td> </tr>'; } $html .= ' <tr><td><p> </p></td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td><td> </td></tr> </tbody></table>'; // Signatories $sr_prepared = $this->Settings->get_selected_field('sr_prepared'); $sr_prepared_position = $this->Settings->get_selected_field('sr_prepared_position'); $sr_certified = $this->Settings->get_selected_field('sr_certified'); $sr_certified_position = $this->Settings->get_selected_field('sr_certified_position'); $html .= ' <table width="100%" border="0"> <tr> <td width="38%"> </td> <td width="23%"> </td> <td width="39%"> </td> </tr> <tr> <td align="center">PREPARED BY:</td> <td> </td> <td align="center">CERTIFIED CORRECT:</td> </tr> <tr> <td align="center"> </td> <td> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </td> <td> </td> <td align="center"> </td> </tr> <tr> <td align="center">' . $sr_prepared . '</td> <td> </td> <td align="center">' . $sr_certified . '</td> </tr> <tr> <td align="center">' . $sr_prepared_position . '</td> <td> </td> <td align="center">' . $sr_certified_position . '</td> </tr> </table> '; $this->load->library('MPDF52/mpdf'); //$this->mpdf->WriteHTML('<p>Hello There hahahaha</p>'); //$this->mpdf->Output('mpdf.pdf','I'); // LOAD a stylesheet $stylesheet = file_get_contents(base_url() . 'css/mpdf/mpdfstyletables.css'); $this->mpdf->WriteHTML($stylesheet, 1); // The parameter 1 tells that this is css/style only and no body/html/text $this->mpdf->WriteHTML($html); $this->mpdf->Output('dtr/template/pds/archives/pds_' . date('Y_m_d') . '.pdf', 'F'); return 'dtr/template/pds/archives/pds_' . date('Y_m_d') . '.pdf'; exit; $this->load->helper('settings'); $this->load->library('fpdf'); //define('FPDF_FONTPATH',$this->config->item('fonts_path')); $this->load->library('fpdi'); // initiate FPDI $pdf = new FPDI('L', 'mm', 'Letter'); // add a page $pdf->AddPage(); // set the sourcefile //$pdf->setSourceFile('dtr/template/service_record/service_record.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(15, 60); $pdf->SetFont('Arial', '', 16); $pdf->Cell(0, 3, "Report Name", '', 1, 'C', false); //$pdf->Ln(4); //$e = new Employee_m(); //$e->get_by_employee_id( $employee_id ); $pdf->SetFont('Arial', '', 12); //$pdf->Cell(0,8,"Employee No.:".$e->id ,'',1,'L',false); //$pdf->Ln(2); //$pdf->SetFont('Arial', '', 12); //$pdf->Cell(0,8,"Employee Name:".$e->lname.', '.$e->fname.' '.$e->mname ,'',1,'L',false); $pdf->Ln(4); $pdf->Cell(0, 8, "Emp ID Name Sex Position/Designation Office Employment Status Salary Grade Eligibility Education Birth Day Address", '1', 1, 'L', false); $pdf->Ln(4); $i = 1; $this->load->helper('text'); //$pdf->Cell(30,12, word_wrap('msayado maahhn ndhah ahhhehe so ano gagawin mo now', 10) ,'1',1,'L',false); //$pdf->MultiCell(30,3,word_wrap("hello this is a sample nlong text with line break ", 15) ,'1',1,'L',false); //$pdf->MultiCell(30,3,word_wrap("hello this is a sample nlong text with line break ", 15) ,'0',1,'L',false); foreach ($rows as $row) { $pdf->SetFont('Arial', '', 11); $pdf->SetX(10); //$pdf->Write(0, $row->id); $pdf->Cell(15, 12, $row->id, '1', 0, 'L', false); $pdf->SetX(29); //$pdf->Write(0, $row->lname.', '.$row->fname.''.$row->mname); $pdf->Cell(30, 12, word_wrap($row->lname . ', ' . $row->fname . '' . $row->mname, 10), '1', 1, 'L', false); $pdf->SetFont('Arial', '', 8); $pdf->SetX(62); $pdf->Write(0, $row->sex); $pdf->SetX(75); //$pdf->Write(0, $row->company); $pdf->Write(0, $row->position); //$pdf->SetFont('Arial', '', 12); $pdf->SetX(160); $pdf->Write(0, $row->movement); //$pdf->SetX(150); //$pdf->Write(0, $row->salary_grade); $pdf->SetFont('Arial', '', 8); $pdf->SetX(185); //$pdf->Write(0, $row->status); if ($row->govt_service == 1) { $row->govt_service = 'Yes'; } else { $row->govt_service = 'No'; } $pdf->SetX(190); //$pdf->Write(0, $row->govt_service); $pdf->SetFont('Arial', '', 12); if ($i == 6 || $i == 10 || $i == 13 || $i == 16 || $i == 19 || $i == 22) { $pdf->Ln(8); } else { $pdf->Ln(7); } $i++; } $pdf->Cell(0, 8, "--------------------------------------------------------- Nothing Follows ---------------------------------------------------------", '', 1, 'C', false); // Signatories $pdf->Ln(15); $pdf->SetX(20); $pdf->Cell(90, 5, "PREPARED BY:", '0', 0, 'C', false); $pdf->Cell(90, 5, "CERTIFIED CORRECT:", '0', 1, 'C', false); $pdf->Ln(10); $sr_prepared = $this->Settings->get_selected_field('sr_prepared'); $sr_prepared_position = $this->Settings->get_selected_field('sr_prepared_position'); $sr_certified = $this->Settings->get_selected_field('sr_certified'); $sr_certified_position = $this->Settings->get_selected_field('sr_certified_position'); $pdf->SetX(20); $pdf->Cell(90, 5, $sr_prepared, '0', 0, 'C', false); //4th param border $pdf->Cell(90, 5, $sr_certified, '0', 1, 'C', false); $pdf->SetX(20); $pdf->Cell(90, 5, $sr_prepared_position, '0', 0, 'C', false); $pdf->Cell(90, 5, $sr_certified_position, '0', 1, 'C', false); // Output $pdf->Output('dtr/template/pds/archives/pds_' . date('Y_m_d') . '.pdf', 'F'); return 'dtr/template/pds/archives/pds_' . date('Y_m_d') . '.pdf'; }
$pdf->Ln(13); $pdf->Cell(28); $pdf->Cell(66, 0, $row["PRIMAANUALCOMP"], 0, 0, "C"); $pdf->Cell(8.6); $pdf->Cell(65.4, 0, $row["PRIMAANUAL"], 0, 0, "C"); $pdf->Ln(8.4); $pdf->Cell(100); $pdf->Cell(40, 0, $row["DIFMENSUAL"], 0, 0, "R"); $pdf->Ln(5.6); $pdf->Cell(100); $pdf->Cell(40, 0, $row["DIFANUALAHORRO"], 0, 0, "R"); $pdf->SetTextColor(255, 255, 255); $pdf->Ln(5.6); $pdf->Cell(100); $pdf->Cell(40, 0, $row["DIFPORCENTUAL"], 0, 0, "R"); $pdf->SetTextColor(0, 0, 0); $pdf->Image(GRAFICO_CARTA_COTIZACION.$_REQUEST["archivo"], 50, 156, 120, 77); // 400, 256 } } $pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_cotizacion/plantillas/carta_cotizacion.pdf"); $pdf->SetDrawColor(255, 255, 255); $pdf->SetFillColor(255, 255, 255); $pdf->AddPage(); $tplIdx = $pdf->importPage(1);
function FlyerRendering($config, $inputFile, $outputPath, $outputPostfix, $anschnitt = 0.0) { // Breite der einzelnen Seiten $wRechts = 99.0; //mm $wMitte = 98.0; //mm $wLinks = 97.0; //mm // Community Name $communityNamePositionX = $wLinks + $wMitte + $config['communityNamePositionOffsetX']; //mm $communityNamePositionY = 12.2 + $config['communityNamePositionOffsetY']; //mm // Kontakt Titel $kontaktTitelPositionX = $wLinks + 3.975; //mm $kontaktTitelPositionY = 10.425; //mm $kontaktTitelFontSize = 15.0; //pt // Kontakt Info $kontaktInfoTextPositionX = $kontaktTitelPositionX + 25.0; //mm $kontaktInfoPositionY = $kontaktTitelPositionY + 7.0; //mm $kontaktInfoZeilenOffsetY = 4.7; //mm $kontaktInfoFontSize = 10.9; //pt // Kontakt Logo $kontaktLogoPositionX = $wLinks + $wMitte / 2 - $config['kontaktLogoWidth'] / 2; // Kontakt Footer $kontaktFooterPositionX = $wLinks; //mm $kontaktFooterPositionY = 95.40000000000001; //mm $kontaktFooterWidth = $wMitte; //mm $kontaktFooterFontSize = 10.9; //pt // Output-Dasteiname zusammenbauen $outputFile = $outputPath . DIRECTORY_SEPARATOR . $outputPostfix . '_' . basename($inputFile); // initiate FPDI $pdf = new FPDI(); echo 'Input: ' . basename($inputFile) . PHP_EOL; $pageCount = $pdf->setSourceFile($inputFile); // Importiere Vorder- und Rueckseite $Vorderseite = $pdf->ImportPage(1); $Rueckseite = $pdf->ImportPage(2); // Seitenabmessungen holen $size = $pdf->getTemplateSize($Vorderseite); $dokumentBreite = round($size['w'], 2); $dokumentHoehe = round($size['h'], 2); echo 'Dokumenten Breite: ' . $dokumentBreite . 'mm' . PHP_EOL; echo 'Dokumenten Hoehe: ' . $dokumentHoehe . 'mm' . PHP_EOL; echo 'Anschnitt: ' . $anschnitt . 'mm' . PHP_EOL; // Vorderseite uebernehmen // Anfang eines bloeden Hacks wegen des FooterZeilen-Textes. // Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist. // Keine Ahnung warum! $pdf->AddPage('L'); $tplVorderseite = $pdf->importPage(1); $pdf->useTemplate($tplVorderseite); //Margin ist wegen der Rand-Platzierung des Community Names wichtig. $pdf->SetMargins(0, 0, 0); // erstmal alle Fonts laden echo 'Lade Fonts...' . PHP_EOL; $pdf->AddFont('lato-bold'); $pdf->AddFont('lato-regular'); $pdf->AddFont('alternategothic'); // Rendern Titel Text echo 'Verarbeite Titel Text...' . PHP_EOL; $pdf->SetFont('lato-bold'); $pdf->SetFontSize($kontaktTitelFontSize); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $config['kontaktTitelText'])); // Rendern Info Text echo 'Verarbeite Info Text...' . PHP_EOL; $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetFontSize($kontaktInfoFontSize); foreach ($config['kontaktInfoTexte'] as $a) { $pdf->SetFont('lato-bold'); $pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0])); $pdf->SetFont('lato-regular'); $pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt); $pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1])); $kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY; } // Rendern Community Logo echo 'Verarbeite Logo...' . PHP_EOL; $pdf->Image($config['kontaktLogoDateiName'], $kontaktLogoPositionX + $anschnitt, $config['kontaktLogoPositionY'] + $anschnitt, $config['kontaktLogoWidth'], 0); // Rendern Fusszeilen Text echo 'Verarbeite Fusszeile...' . PHP_EOL; $pdf->SetFont('lato-regular'); $pdf->SetFontSize($kontaktFooterFontSize); $pdf->SetTextColor(255, 255, 255); //weiss $pdf->SetXY($kontaktFooterPositionX + $anschnitt, $kontaktFooterPositionY + $anschnitt); $pdf->Cell($kontaktFooterWidth, 0, iconv('UTF-8', 'windows-1252', $config['kontaktFusszeileText']), 0, 0, 'C'); // Rendern Community Name echo 'Verarbeite Community Name...' . PHP_EOL; $pdf->SetFont('alternategothic'); $pdf->SetFontSize($config['communityNameFontSize']); $pdf->SetTextColor(0, 0, 0); //schwarz $pdf->SetXY($communityNamePositionX + $anschnitt, $communityNamePositionY + $anschnitt); $pdf->MultiCell($wRechts, 10, iconv('UTF-8', 'windows-1252', $config['communityNameText']), 0, 'C'); // Das war's mit dem Editieren // Original PDF Rueckseit uebernehmen $pdf->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf->importPage(2); $pdf->useTemplate($tplRueckseite); // und erstmal abspeichern echo 'Zwischenspeichern...' . PHP_EOL; $pdf->Output($outputFile); // Hier geht jetzt der Hack wegen der Footerzeile weiter // Die gerade abgespeicherte Datei wird erneut eingelesen // um dann im Seiten-Format der Ursprungsdatei erneut abgespeichert zu werden. // Is' doof, muss aber sein $pdf_2 = new FPDI(); echo 'Erneut laden...' . PHP_EOL; $pageCount = $pdf_2->setSourceFile($outputFile); echo 'Feinschliff...' . PHP_EOL; $Vorderseite_2 = $pdf_2->ImportPage(1); $Rueckseite_2 = $pdf_2->ImportPage(2); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplVorderseite = $pdf_2->importPage(1); $pdf_2->useTemplate($tplVorderseite); $pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe)); $tplRueckseite = $pdf_2->importPage(2); $pdf_2->useTemplate($tplRueckseite); echo 'Output: ' . basename($outputFile) . PHP_EOL; $pdf_2->Output($outputFile); unset($pdf); unset($pdf_2); }
$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 ($row['study_type'] == "Денна") { $type = ", денна форма навчання"; } if ($row['study_type'] == "Заочна") { $type = ", заочна форма навчання";
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'; }