public function testPdfOutput() { // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) $pdf->setLanguageArray($this->langSettings); // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('dejavusans', '', 14, '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); // set text shadow effect $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); // Set some content to print $html = <<<EOD <h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;"> <span style="color:black;">TC</span><span style="color:white;">PDF</span> </a>!</h1> <i>This is the first example of TCPDF library.</i> <p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p> <p>Please check the source code documentation and other examples for further information.</p> <p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p> EOD; // Print text using writeHTMLCell() $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); $this->comparePdfs($pdf); }
/** * @param TicketsOrder $order * @param string $format 'S': data string - 'I' to see in browser * @return string */ public function getPdfFileData(TicketsOrder $order, $format = 'S') { $pdf = new \TCPDF(); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Billets du Louvre'); $pdf->SetTitle('Commande ' . $order->getRef()); $pdf->setPrintHeader(false); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set style for barcode $style = array('border' => 0, 'vpadding' => 'auto', 'hpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1); /** @var Ticket $ticket */ foreach ($order->getTickets() as $ticket) { $pdf->AddPage(); $html = $this->renderTicket(array('visit_date' => $order->getVisitDate()->format('d/m/Y'), 'visit_duration' => $order->getVisitDuration(), 'code' => $order->getRef(), 'ticket_name' => $ticket->getName(), 'price' => $ticket->getPrice(), 'details' => $ticket->getTicketDetails())); $pdf->writeHTML($html, true, false, true); $pdf->write2DBarcode($order->getRef(), 'QRCODE,H', 150, 10, 50, 50, $style, 'N'); $pdf->lastPage(); } return $pdf->Output('tickets.pdf', $format); }
public function pdfthongkeAction() { $translate = Zend_Registry::get('Zend_Translate'); $this->view->title = 'Thống kê - ' . $translate->_('TEXT_DEFAULT_TITLE'); $this->view->headTitle($this->view->title); $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED; $option = array('layout' => '1_column/layout', 'layoutPath' => $layoutPath); Zend_Layout::startMvc($option); $date = new Zend_Date(); $date->subMonth(1); $thang = $this->_getParam('thang', $date->toString('M')); $nam = $this->_getParam('nam', $date->toString('Y')); $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); $em_id = $identity->em_id; $emModel = new Front_Model_Employees(); $phongbanModel = new Front_Model_Phongban(); $my_info = $emModel->fetchRow('em_id=' . $em_id . ' and em_status=1'); $phong_ban_id = $list_phongban = $phong_ban = array(); if ($my_info) { $phong_ban_id[] = $my_info->em_phong_ban; $list_phongban = $phongbanModel->fetchDataStatus($my_info->em_phong_ban, $phong_ban); } if (sizeof($list_phongban)) { foreach ($list_phongban as $phong_ban_info) { $phong_ban_id[] = $phong_ban_info->pb_parent; } } $phong_ban_id = implode(',', $phong_ban_id); $list_nhan_vien = $emModel->fetchAll("em_phong_ban in ({$phong_ban_id}) and em_status=1"); $holidaysModel = new Front_Model_Holidays(); $holidays = $holidaysModel->fetchData(); $listHoliday = array(); foreach ($holidays as $holiday) { $listHoliday[$holiday['hld_id']] = $holiday['hld_code']; } $k = 0; if ($list_nhan_vien) { $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(PDF_AUTHOR); $pdf->SetTitle(PDF_HEADER_TITLE); $pdf->SetSubject(PDF_HEADER_TITLE); $pdf->SetKeywords('bang luong'); $pdf->setPrintHeader(false); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(5, PDF_MARGIN_TOP, 5); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setFontSubsetting(true); $pdf->SetFont('dejavusans', '', 14, '', true); $pdf->AddPage('L', 'A4'); $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); $text_outout = ' <style> .ten-co-quan { color: #000; font-size: 10pt; height: 50px; text-align:center; } .ten-bang-luong{ height: 30px; text-align:center; font-size: 10pt; } table.first { color: #003300; font-family: helvetica; font-size: 8pt; border-left: 3px solid red; border-right: 3px solid #FF00FF; border-top: 3px solid green; border-bottom: 3px solid blue; background-color: #ccffcc; } .borders { border: 1px solid #000; font-size: 10px; } .tieu-de{ height: 20px; font-size: 11px; } .noi-dung{ font-size: 10px; } td.second { border: 2px dashed green; } .lowercase { text-transform: lowercase; } .uppercase { text-transform: uppercase; } .capitalize { text-transform: capitalize; } .error{ background-color: #dddddd; } </style> <table width="100%"> <tr> <td width="200" class="ten-co-quan uppercase"> TỔNG CỤC HẢI QUAN <div><strong>CỤC HẢI QUAN HÀ TĨNH</strong></div> </td> <td colspan="2"> </td> </tr> <tr> <td colspan="3" class="ten-bang-luong uppercase">BẢNG CHẤM CÔNG VÀ XẾP LOẠI A,B,C THÁNG ' . $thang . '-' . $nam . '</td> </tr>'; $text_outout .= '<tr> <td colspan="3"> <br/> <table border="1" class="noi-dung" cellpadding="5" nobr="true"> <tr> <td style="width: 25pt;" rowspan="2"><strong>STT</strong></td> <td style="width: 70pt;" rowspan="2"><strong>HỌ TÊN</strong></td> <td colspan="31" style="text-align:center;"><strong>Ngày Công Trong Tháng</strong></td> <td style="width: 50pt;" rowspan="2"><strong>Phân loại A,B,C</strong></td> <td style="width: 50pt;" rowspan="2"><strong>Ghi chú</strong></td> </tr> <tr>'; for ($i = 1; $i <= 31; $i++) { $text_outout .= '<td >' . $i . '</td>'; } $text_outout .= '</tr>'; $k = 0; $chamcongModel = new Front_Model_ChamCong(); foreach ($list_nhan_vien as $nhan_vien) { $phan_loai_label = 'A'; $phan_loai = $this->view->viewGetPhanLoai($nhan_vien->em_id, $thang, $nam); if ($phan_loai) { $phan_loai_label = $phan_loai->dg_ptccb_status; if (!$phan_loai_label || $phan_loai_label == null || $phan_loai_label == '-') { $phan_loai_label = 'A'; } } else { $phan_loai_label = ''; } $text_outout .= '<tr>'; $k++; $cham_cong = $chamcongModel->fetchOneData(array('c_em_id' => $nhan_vien['em_id'], 'c_thang' => (int) $thang, 'c_nam' => (int) $nam)); $text_outout .= '<td>' . $k . '</td>'; $text_outout .= '<td>' . $nhan_vien->em_ho . ' ' . $nhan_vien->em_ten_dem . ' ' . $nhan_vien->em_ten . '</td>'; for ($i = 1; $i <= 31; $i++) { $ngay_chamcong = 'c_ngay_' . $i; $trangthai_ngaycong = $cham_cong->{$ngay_chamcong}; $status = !empty($listHoliday[$trangthai_ngaycong]) ? $listHoliday[$trangthai_ngaycong] : ' '; $text_outout .= '<td ' . $this->view->viewCheckChuNhatThuBay($i, (int) $thang, (int) $nam) . '>' . $status . '</td>'; } $text_outout .= '<td>' . $phan_loai_label . '</td>'; $text_outout .= '<td></td>'; $text_outout .= '</tr>'; } $text_outout .= '</table> </td> </tr>'; $text_outout .= '</table> </td> </tr>'; $text_outout .= '<tr><td style=""></td><td style="width: 120pt;"> </td><td style="width: 50pt;"> </td></tr>'; foreach ($holidays as $holiday) { $text_outout .= '<tr class="noi-dung"><td style="width: 32pt;"></td><td style="width: 70pt;">' . $holiday['hld_name'] . '</td><td style="width: 50pt;">' . $holiday['hld_code'] . '</td></tr>'; } $text_outout .= '</table> '; $pdf->writeHTMLCell(0, 0, '', '', $text_outout, 0, 1, 0, true, '', true); $pdf->Output($file_name, 'I'); die; $k += 5; foreach ($holidays as $holiday) { $k++; $objPHPExcel->getActiveSheet()->SetCellValue('B' . ($k + 7), $holiday['hld_name']); $objPHPExcel->getActiveSheet()->SetCellValue('C' . ($k + 7), $holiday['hld_code']); } if ($k) { $objPHPExcel->getActiveSheet()->setTitle('Bảng lương'); if ($pb_selected && $phong_ban_selected_info) { $file_name = 'Thong_ke_luong_' . str_replace(' ', '_', $this->loc_tieng_viet($phong_ban_selected_info->pb_name)) . '_' . $thang . '-' . $nam . '.xls'; } else { $file_name = 'Thong_ke_luong_' . $thang . '-' . $nam . '.xls'; } header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename = "' . $file_name . '"'); header('Cache-Control: max-age = 0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); die; /* $file_name = 'Bang_luong_.xls'; $objPHPExcel->getActiveSheet()->setTitle('Bảng lương'); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="hungnm.xls"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); */ } else { $this->_helper->viewRenderer->setRender('loi'); } } else { $this->_helper->viewRenderer->setRender('loi'); } }
public function executeIndex(sfWebRequest $request) { $i18n = sfContext::getInstance()->getI18N(); // Disable CSRF protection $this->form = new ReportingForm(array(), array(), false); $formName = $this->form->getName(); $this->step = sfConfig::get('app_max_reservations_on_reporting'); $this->getUser()->syncParameters($this, 'reporting', 'index', array('offset', 'limit', $formName, 'sort_column', 'sort_direction'), $request); if (is_null($this->sort_column)) { $this->sort_column = 'date'; $this->sort_direction = 'up'; } if (is_null($this->offset)) { $this->offset = 0; } if (is_null($this->limit) || $this->limit <= 0) { $this->limit = $this->step; } $c = new Criteria(); SortCriteria::addSortCriteria($c, $this->sort_column, ReservationPeer::getSortAliases(), $this->sort_direction); $this->filtered = false; if (!is_null($this->{$formName})) { $this->filtered = true; $this->form->bind($this->{$formName}, $request->getFiles($formName)); if ($this->form->isValid()) { $this->reservation_list = ReservationPeer::report($this->form->getValue('users'), $this->form->getValue('usergroups'), $this->form->getValue('activities'), $this->form->getValue('zones'), $this->form->getValue('rooms'), strtotime($this->form->getValue('begin_date')), strtotime($this->form->getValue('end_date')), $c); $this->count = count($this->reservation_list); $this->entire_reservation_list = $this->reservation_list; $this->reservation_list = array_slice($this->reservation_list, $this->offset, $this->limit); } else { $this->count = 0; $this->reservation_list = array(); } } else { $this->count = 0; $this->reservation_list = array(); } if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) { $this->forward404('Invalid offset/count values.'); } if (!is_null($export = $request->getParameter('export'))) { $this->forward404Unless(in_array($export, array('csv', 'pdf')), sprintf('Unhandled value "%s" for export', $export)); sfConfig::set('sf_web_debug', false); $activity_name = ConfigurationHelper::getParameter('Rename', 'activity_label'); if (empty($activity_name)) { $activity_name = $i18n->__('Activity'); } $free_field_1_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_1'); $free_field_2_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_2'); $free_field_3_name = ConfigurationHelper::getParameter('Rename', 'reservation_custom_field_3'); $this->all_rows = array(); $fields = $this->form->getValue('fields'); foreach ($this->entire_reservation_list as $reservation) { //If there's is a temporary group, we modify the name to display "Perso. (first user, ...)" $resa_group_name = null; $ug = $reservation->getUsergroup(); if (!is_null($ug)) { $resa_group_name = $ug->getName(); } $this->all_rows[] = array(); end($this->all_rows); // Check which field we need to display. foreach ($fields as $field_id) { // See lib\form\ReportingForm.class.php for indexes switch ($field_id) { case 0: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Date'), $reservation->getDate()); break; case 1: $this->all_rows[key($this->all_rows)][] = array($i18n->__('User'), $reservation->getUser()->getFullName()); break; case 2: $this->all_rows[key($this->all_rows)][] = array($activity_name, $reservation->getActivity()->getName()); break; case 3: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Duration'), number_format($reservation->getDuration())); break; case 4: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Room'), $reservation->getRoomprofile()->getRoom()->getName()); break; case 5: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Reason'), !is_null($reservation->getReservationreason()) ? $reservation->getReservationreason()->getName() : null); break; case 6: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Comment'), $reservation->getComment()); break; case 7: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Group'), $resa_group_name); break; case 8: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Members count'), number_format($reservation->getMembersCount())); break; case 9: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Guests count'), number_format($reservation->getGuestsCount())); break; case 10: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Status'), number_format($reservation->getStatus())); break; case 11: $this->all_rows[key($this->all_rows)][] = array($i18n->__('Price'), number_format($reservation->getPrice())); break; case 12: $valuedFeaturesArray = $reservation->getRoomprofile()->getRoom()->getValuedFeaturesArray(); $concat = ''; foreach ($valuedFeaturesArray as $featureName => $values) { $concat .= $featureName . '=' . $values . ' | '; } $concat = rtrim($concat, ' | '); $this->all_rows[key($this->all_rows)][] = array($i18n->__('Features'), $concat); break; case 90: $this->all_rows[key($this->all_rows)][] = array($free_field_1_name, $reservation->getCustom1()); break; case 91: $this->all_rows[key($this->all_rows)][] = array($free_field_2_name, $reservation->getCustom2()); break; case 92: $this->all_rows[key($this->all_rows)][] = array($free_field_3_name, $reservation->getCustom3()); break; } } } if ($export == 'csv') { $this->setLayout(false); $this->getResponse()->clearHttpHeaders(); $this->getResponse()->setHttpHeader('Pragma: public', true); $this->getResponse()->setHttpHeader('Content-disposition', sprintf('attachment; filename="%s"', 'reporting-' . date('Y-m-d') . '.csv')); $this->getResponse()->setContentType('text/csv; charset=utf-8'); $this->getResponse()->sendHttpHeaders(); $this->setTemplate('exportCSV'); } else { if ($export == 'pdf') { $config = sfTCPDFPluginConfigHandler::loadConfig(); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('ISLOG Tempos'); $pdf->SetTitle('Tempos report export'); $pdf->SetSubject('Tempos export'); $pdf->SetKeywords('Tempos, report, ISLOG'); $pdf->SetHeaderData(sfConfig::get('app_has_logo'), PDF_HEADER_LOGO_WIDTH, $i18n->__('Report'), sprintf($i18n->__('Usage report from %s to %s'), $this->form->getValue('begin_date'), $this->form->getValue('end_date'))); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setFontSubsetting(true); $pdf->SetFont('dejavusans', '', 10, '', true); $pdf->AddPage(); $this->writeHtmlTable($pdf, $this->all_rows); $pdf->Output('reporting-' . date('Y-m-d') . '.pdf', 'I'); exit; } } } }
include '../../protected/config/db_config.php'; $db = new db_config(); $connect = $db->connect(); // create new PDF document //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // add a page $pdf = new TCPDF(); //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', true, 'UTF-8', false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->SetCreator(PDF_CREATOR); //$pdf->SetAuthor('Nicola Asuni'); $pdf->SetSubject(''); $pdf->SetKeywords(''); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . 'ZÁRIL lifestyle store', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 1, 0), array(0, 1, 1)); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $resolution = array(80, 100); $pdf->AddPage('P', $resolution); $pdf->SetTitle('Tenant Sales Report'); $html = $_GET['html']; #$html .='<div>'. $html .'</div>'; $pdf->writeHTML($html, false, false, true, false, ''); $pdf->Output('..');
<?php // Include the main TCPDF library (search for installation path). require_once 'tcpdf_include.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128)); //$pdf->setFooterData(array(0,64,0), array(0,64,128)); $pdf->setFooterData(PDF_FOOTER_STRING, array(0, 64, 0), array(0, 64, 128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . 'lang/spa.php')) {
public function ConstructFlightEventsList($extFlightId, $sections = [], $colored = false) { $flightId = $extFlightId; $user = $this->_user->username; $Fl = new Flight(); $flightInfo = $Fl->GetFlightInfo($flightId); $bruType = $flightInfo['bruType']; unset($Fl); $Bru = new Bru(); $bruInfo = $Bru->GetBruInfo($bruType); $flightApHeaders = $Bru->GetBruApHeaders($bruType); $flightBpHeaders = $Bru->GetBruBpHeaders($bruType); $prefixArr = $Bru->GetBruApCycloPrefixes($bruType); unset($Bru); $Frame = new Frame(); $framesCount = $Frame->GetFramesCount($flightInfo['apTableName'], $prefixArr[0]); //giving just some prefix unset($Frame); // create new PDF document $pdf = new TCPDF('L', 'mm', 'A4', true, 'UTF-8', false); // set document information $pdf->SetCreator($user); $pdf->SetAuthor($user); $pdf->SetTitle('Flight events list'); $pdf->SetSubject('Flight events list'); // $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); $bort = $flightInfo['bort']; $voyage = $flightInfo['voyage']; $copyDate = date('H:i:s d-m-Y', $flightInfo['startCopyTime']); $Fr = new Frame(); $flightDuration = $Fr->FrameCountToDuration($framesCount, $bruInfo['stepLength']); unset($Fr); $usrInfo = $this->_user->userInfo; $headerStr = $usrInfo['company']; $imageFile = ''; if ($colored && $usrInfo['logo'] != '') { $imageFile = SITE_ROOT_DIR . '/fileUploader/files/' . uniqid() . '.png'; file_put_contents($imageFile, $usrInfo['logo']); $img = file_get_contents($imageFile); $pdf->SetHeaderData('$' . $img, "20", $headerStr, "", [0, 10, 50], [0, 10, 50]); } else { // set default header data $pdf->SetHeaderData("", "", $headerStr, "", [0, 10, 50], [0, 10, 50]); } $pdf->setFooterData([0, 10, 50], [0, 10, 50]); // set header and footer fonts $pdf->setHeaderFont(array('dejavusans', '', 11)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('dejavusans', '', 12, '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); if ($imageFile !== '') { unlink($imageFile); } // set text shadow effect $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => [196, 196, 196], 'opacity' => 1, 'blend_mode' => 'Normal')); // Pasport $strStyle = "text-align:center; font-size: xx-large; font-weight: bold; color: rgb(0, 10, 64);"; $str = '<p style="' . $strStyle . '">' . $this->lang->pasport . '</p>'; $pdf->writeHTML($str, true, false, false, false, ''); // Pasport info $strStyle = "text-align:center;"; $str = '<p style="' . $strStyle . '">' . $this->lang->bruType . ' - ' . $bruInfo['bruType'] . '. <br>' . $this->lang->bort . ' - ' . $flightInfo['bort'] . '; ' . $this->lang->voyage . ' - ' . $flightInfo['voyage'] . '; ' . $this->lang->route . ' : ' . ($new_string = preg_replace('/[^a-zA-z0-9]/', '', $flightInfo['departureAirport']) . ' - ' . preg_replace('/[^a-zA-z1-9]/', '', $flightInfo['arrivalAirport']) . '. <br>' . $this->lang->flightDate . ' - ' . date('H:i:s d-m-Y', $flightInfo['startCopyTime']) . '; ' . $this->lang->duration . ' - ' . $flightDuration . '. <br>'); $fileName = date('Y-m-d_H.i.s', $flightInfo['startCopyTime']) . '_' . $flightInfo['bort'] . '_' . $flightInfo['voyage'] . '_' . $bruInfo['bruType']; if (strpos($bruInfo['aditionalInfo'], ";") >= 0) { $counterNeedBrake = false; $aditionalInfoArr = explode(";", $flightInfo['flightAditionalInfo']); foreach ($aditionalInfoArr as $aditionalInfo) { if ($aditionalInfo != "") { $nameVal = explode(":", $aditionalInfo); if (count($nameVal) > 1) { $name = $nameVal[0]; $val = $nameVal[1]; if ($counterNeedBrake) { $str .= (isset($this->lang->{$name}) ? $this->lang->{$name} : $name) . " - " . $val . "; </br>"; $counterNeedBrake = !$counterNeedBrake; } else { $str .= (isset($this->lang->{$name}) ? $this->lang->{$name} : $name) . " - " . $val . "; "; $counterNeedBrake = !$counterNeedBrake; } } } } } $str .= "</p>"; $pdf->writeHTML($str, true, false, false, false, ''); if ($flightInfo['exTableName'] != "") { $FEx = new FlightException(); $excEventsList = $FEx->GetFlightEventsList($flightInfo['exTableName']); $Frame = new Frame(); // change frame num to time for ($i = 0; $i < count($excEventsList); $i++) { $event = $excEventsList[$i]; $excEventsList[$i]['start'] = date("H:i:s", $excEventsList[$i]['startTime'] / 1000); $reliability = "checked"; // converting false alarm to reliability if ($excEventsList[$i]['falseAlarm'] == 0) { $reliability = true; } else { $reliability = false; } $excEventsList[$i]['reliability'] = $reliability; $excEventsList[$i]['end'] = date("H:i:s", $excEventsList[$i]['endTime'] / 1000); $excEventsList[$i]['duration'] = $Frame->TimeStampToDuration($excEventsList[$i]['endTime'] - $excEventsList[$i]['startTime']); } unset($Frame); // if isset events if (!empty($excEventsList)) { $pdf->SetFont('dejavusans', '', 9, '', true); $strStyle = 'style="text-align:center; font-weight: bold; background-color:#708090; color:#FFF"'; $str = '<p><table border="1" cellpadding="1" cellspacing="1">' . '<tr ' . $strStyle . '><td width="70"> ' . $this->lang->start . '</td>' . '<td width="70">' . $this->lang->end . '</td>' . '<td width="70">' . $this->lang->duration . '</td>' . '<td width="70">' . $this->lang->code . '</td>' . '<td width="260">' . $this->lang->eventName . '</td>' . '<td width="110">' . $this->lang->algText . '</td>' . '<td width="180">' . $this->lang->aditionalInfo . '</td>' . '<td width="110">' . $this->lang->comment . '</td></tr>'; for ($i = 0; $i < count($excEventsList); $i++) { $event = $excEventsList[$i]; $excInfo = $FEx->GetExcInfo($bruInfo['excListTableName'], $event['refParam'], $event['code']); $codePrefix = substr($event['code'], 0, 3); if ($event['reliability'] && (in_array($codePrefix, $sections) || !preg_match('/00[0-9]/', $codePrefix) && in_array('other', $sections))) { if ($colored && $excInfo['status'] == "C") { $style = "background-color:LightCoral"; } else { if ($colored && $excInfo['status'] == "D") { $style = "background-color:LightYellow"; } else { if ($colored && $excInfo['status'] == "E") { $style = "background-color:LightGreen"; } else { $style = ""; } } } $excAditionalInfo = $event['excAditionalInfo']; $excAditionalInfo = str_replace(";", ";<br>", $excAditionalInfo); $excInfo['algText'] = str_replace('<', "less", $excInfo['algText']); $str .= '<tr style="' . $style . '" nobr="true">' . '<td width="70" style="text-align:center;">' . $event['start'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['end'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['duration'] . '</td>' . '<td width="70" style="text-align:center;">' . $event['code'] . '</td>' . '<td width="260" style="text-align:center;">' . $excInfo['comment'] . '</td>' . '<td width="110" style="text-align:center;">' . $excInfo['algText'] . '</td>' . '<td width="180" style="text-align:center;">' . $excAditionalInfo . '</td>' . '<td width="110" style="text-align:center;"> ' . $event['userComment'] . '</td></tr>'; } } unset($FEx); $str .= "</table></p>"; $pdf->writeHTML($str, false, false, false, false, ''); $pdf->SetFont('dejavusans', '', 12, '', true); $str = "</br></br>" . $this->lang->performer . ' : ' . '_____________________ ' . $flightInfo['performer'] . ', ' . date('d-m-Y') . ''; $pdf->writeHTML($str, false, false, false, false, ''); } else { $strStyle = "text-align:center; font-size: xx-large; font-weight: bold; color: rgb(128, 10, 0);"; $str = '<p style="' . $strStyle . '">' . $this->lang->noEvents . '</p>'; $pdf->writeHTML($str, false, false, false, false, ''); } } $pdf->Output($fileName, 'I'); }
public function rekapitulasi_lahan_kecamatan_pdf($tahun, $periode) { /// create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Dinas PU CKTR Sidoarjo'); $pdf->SetTitle('Rekapitulasi_Lahan_Perkecamatan_Triwulan' . $periode . '_' . $tahun); $pdf->SetSubject('TCPDF'); $pdf->SetKeywords('TCPDF, PDF'); $pdf->SetHeaderData('sidoardjo.png', 20, 'PEMERINTAH KABUPATEN SIDOARDJO', 'DINAS PEKERJAAN UMUM CIPTA KARYA DAN TATA RUANG', 'REKAPITULASI DATA LAHAN PERUMAHAH / PEMUKIMAN'); $pdf->setFooterData('Triwulan ' . $periode . ' Tahun ' . $tahun); $pdf->setBarcode(date('Y-m-d H:i:s')); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'B', 20); // add a page $pdf->AddPage('L', 'A3'); // $pdf->Write(0, 'PEMBANGUNAN PERUMAHAN / PEMUKIMAN', '', 0, 'C', true, 0, false, false, 0); // $pdf->Write(0, 'REKAPITULASI DATA LAHAN PERUMAHAH / PEMUKIMAN', '', 0, 'C', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 11); // $pdf->Write(0, 'Tahun :' .$tahun, '', 0, 'L', true, 0, false, false, 0); // $pdf->Write(0, 'Periode : Triwulan' .$periode, '', 0, 'L', true, 0, false, false, 0); $pdf->SetLineWidth(5); $pdf->SetDrawColor(0, 128, 255); $pdf->SetFillColor(255, 255, 128); // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- $k['JML_IJIN_LOKASI'] = $k['LUAS'] = $k['RENCANA_TAPAK'] = $k['PEMBEBASAN'] = $k['TERBANGUN'] = $k['BELUM_TERBANGUN'] = $k['DIALOKASIKAN'] = $k['PEMBEBASAN'] = $k['DIMATANGKAN'] = $k['AKTIF_DLM_PEMBANGUNAN'] = $k['AKTIF_BERHENTI'] = $k['AKTIF_SDH_SELESAI'] = $k['TIDAK_AKTIF'] = 0; $tb = ""; $this->load->model('m_report'); $nilai = $this->m_report->jumlah_kecamatan(); foreach ($nilai as $nil) { $jmlkec = $nil['JUMLAH']; $data['jumlah'] = $nil['JUMLAH']; } for ($j = 1; $j <= $jmlkec; $j++) { $data['lah_kec'][$j] = $this->m_report->tabel_lahan_kecamatan_all($j, $tahun, $periode); $data['aktifpemb'][$j] = $this->m_report->aktif_dalam_pembangunan($j, $tahun, $periode); $data['aktifber'][$j] = $this->m_report->aktif_berhenti($j, $tahun, $periode); $data['aktifsel'][$j] = $this->m_report->aktif_sdh_selesai($j, $tahun, $periode); $data['tdkaktif'][$j] = $this->m_report->tidak_aktif($j, $tahun, $periode); } for ($c = 1; $c < $jmlkec; $c++) { foreach ($data['lah_kec'][$c] as $i) { $tb .= "<tr>\n <td width=\"28px\">" . $c . "</td>\n <td width=\"100px\">" . $i['NAMA_KECAMATAN'] . "</td> \n <td width=\"87px\">" . $i['JML_IJIN_LOKASI'] . " </td>\n <td width=\"87px\">" . $i['LUAS'] . " </td>\n <td width=\"87px\">" . $i['RENCANA_TAPAK'] . " </td>\n <td width=\"90px\">" . $i['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $i['TERBANGUN'] . " </td>\n <td width=\"87px\">" . $i['BELUM_TERBANGUN'] . " </td>\n <td width=\"90px\">" . $i['DIALOKASIKAN'] . " </td>\n <td width=\"90px\">" . $i['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $i['DIMATANGKAN'] . " </td>"; $k['JML_IJIN_LOKASI'] += $i['JML_IJIN_LOKASI']; $k['LUAS'] += $i['LUAS']; $k['RENCANA_TAPAK'] += $i['RENCANA_TAPAK']; $k['PEMBEBASAN'] += $i['PEMBEBASAN']; $k['TERBANGUN'] += $i['TERBANGUN']; $k['BELUM_TERBANGUN'] += $i['BELUM_TERBANGUN']; $k['DIALOKASIKAN'] += $i['DIALOKASIKAN']; $k['PEMBEBASAN'] += $i['PEMBEBASAN']; $k['DIMATANGKAN'] += $i['DIMATANGKAN']; } foreach ($data['aktifpemb'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['AKTIF_DLM_PEMBANGUNAN'] . "</td>"; $k['AKTIF_DLM_PEMBANGUNAN'] += $i['AKTIF_DLM_PEMBANGUNAN']; } foreach ($data['aktifber'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['AKTIF_BERHENTI'] . " </td>"; $k['AKTIF_BERHENTI'] += $i['AKTIF_BERHENTI']; } foreach ($data['aktifsel'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['AKTIF_SDH_SELESAI'] . " </td>"; $k['AKTIF_SDH_SELESAI'] += $i['AKTIF_SDH_SELESAI']; } foreach ($data['tdkaktif'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['TIDAK_AKTIF'] . " </td> \n </tr> "; $k['TIDAK_AKTIF'] += $i['TIDAK_AKTIF']; } } $tb1 = ""; $tb1 .= "<tr>\n \n <td width=\"130px\">JUMLAH</td>\n <td width=\"87px\">" . $k['JML_IJIN_LOKASI'] . " </td>\n <td width=\"87px\">" . $k['LUAS'] . " </td>\n <td width=\"87px\">" . $k['RENCANA_TAPAK'] . " </td>\n <td width=\"90px\">" . $k['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $k['TERBANGUN'] . " </td>\n <td width=\"87px\">" . $k['BELUM_TERBANGUN'] . " </td>\n <td width=\"90px\">" . $k['DIALOKASIKAN'] . " </td>\n <td width=\"90px\">" . $k['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $k['DIMATANGKAN'] . " </td>\n <td width=\"87px\">" . $k['AKTIF_DLM_PEMBANGUNAN'] . " </td>\n <td width=\"87px\">" . $k['AKTIF_BERHENTI'] . " </td>\n <td width=\"87px\">" . $k['AKTIF_SDH_SELESAI'] . " </td>\n <td width=\"87px\">" . $k['TIDAK_AKTIF'] . " </td>\n \n </tr> "; $tbl = <<<EOD <table border="1" cellpadding="2" cellspacing="2"> <thead> <tr style="background-color:#FFFF00;color:#0000FF;"> <td width="28px" align="center"><b>NO</b></td> <td width="100px" align="center"><b>Kecamatan</b></td> <td width="87px " align="center"> <b>Perusahaan</b></td> <td width="87px" align="center"><b>Nama Perumahaan</b></td> <td width="87px" align="center"><b>Nama Lokasi (Ha)</b></td> <td width="87px" align="center"><b>No Lokasi</b></td> <td width="87px" align="center"><b>Tanggal Lokasi Dimiliki</b></td> <td width="87px" align="center"><b>Luas Lokasi</b></td> <td width="87px" align="center"><b>Rencana Tapak</b></td> <td width="90px" align="center"><b>Pembebasan</b></td> <td width="87px" align="center"><b>Terbangun</b></td> <td width="87px" align="center"><b>Belum Terbangun</b></td> <td width="90px" align="center"><b>Dialokasikan</b></td> <td width="90px" align="center"><b>Pembebasan</b></td> <td width="87px" align="center"><b>Sudah Dimatangkan</b></td> </tr> </thead> {$tb} {$tb1} </table> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); $tb = ""; $tb1 = ""; $this->load->model('m_report'); $data1 = $this->m_report->tabel_lahan_kecamatan_all_statistic($tahun - 1); $data2 = $this->m_report->tabel_lahan_kecamatan_all_statistic($tahun - 2); foreach ($data2 as $i) { $tb .= "<tr> \n \n <td width=\"320px\">JUMLAH PENGEMBANG\n <br>JUMLAH IJIN LOKASI\n <br>LUAS IJIN LOKASI\n <br>RENCANA TAPAK\n <br>PEMBEBASAN\n <br>TERBANGUN\n <br>BELUM TERBANGUN\n </td>\n <td width=\"200px\">" . $i['JML_PENGEMBANG'] . "\n <br>" . $i['JML_IJIN_LOKASI'] . "\n <br>" . $i['LUAS'] . "\n <br>" . $i['RENCANA_TAPAK'] . "\n <br>" . $i['PEMBEBASAN'] . "\n <br>" . $i['TERBANGUN'] . "\n <br>" . $i['BELUM_TERBANGUN'] . "\n </td>"; } foreach ($data1 as $i) { $tb .= "<td width=\"200px\">" . $i['JML_PENGEMBANG'] . "\n <br>" . $i['JML_IJIN_LOKASI'] . "\n <br>" . $i['LUAS'] . "\n <br>" . $i['RENCANA_TAPAK'] . "\n <br>" . $i['PEMBEBASAN'] . "\n <br>" . $i['TERBANGUN'] . "\n <br>" . $i['BELUM_TERBANGUN'] . "\n </td> \n </tr> "; } $th1 = $tahun - 1; $th2 = $tahun - 2; $tbl = <<<EOD <table border="1" cellpadding="2" cellspacing="2"> <thead> <tr style="background-color:#FFFF00;color:#0000FF;"> <td width="320px" align="center"><b>TYPE RUMAH</b></td> <td width="200px " align="center"> <b>DES {$th2}</b></td> <td width="200px " align="center"> <b>DES {$th1}</b></td> </tr> </thead> {$tb} {$tb1} </table> EOD; //print_r($tbl); $pdf->writeHTML($tbl, true, false, false, false, ''); $pdf->Output('Rekapitulasi_Lahan_Perkecamatan_Triwulan' . $periode . '_' . $tahun . '.pdf', 'I'); }
require_once 'lib/tcpdf/tcpdf.php'; date_default_timezone_set("PRC"); $json = json_decode($_POST['content']); if ($json) { //实例化 $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); // 设置文档信息 $pdf->SetCreator('today.exformation.com.cn'); $pdf->SetAuthor('today.exformation.com.cn'); $pdf->SetTitle($json->today); $pdf->SetSubject($json->today); $pdf->SetKeywords($json->today); // 设置页眉和页脚信息 $pdf->SetHeaderData('', 0, '今日|' . $json->today, 'today.exformation.com.cn'); $pdf->setFooterData('today.exformation.com.cn'); // 设置页眉和页脚字体 $pdf->setHeaderFont(array('droidsansfallback', '', '10')); $pdf->setFooterFont(array('helvetica', '', '8')); // 设置默认等宽字体 $pdf->SetDefaultMonospacedFont('courier'); // 设置间距 $pdf->SetMargins(15, 21, 15); $pdf->SetHeaderMargin(5); $pdf->SetFooterMargin(10); $pdf->setCellHeightRatio(0.7); // 设置分页 $pdf->SetAutoPageBreak(TRUE, 25); // set image scale factor $pdf->setImageScale(1.25); // set default font subsetting mode
<?php // Include the main TCPDF library (search for installation path). require_once 'tcpdf.php'; require_once 'config/eng.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('PGIpharm'); $pdf->SetTitle('PGIpharm drug response report'); $pdf->SetSubject(''); $pdf->SetKeywords('PGI, PDF, research, test, report'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0, 0, 0), array(0, 0, 0)); $pdf->setFooterData(array(0, 0, 0), array(0, 0, 0)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) // ---------------------------------------------------------
public function create_pdf() { /** * Creates an example PDF TEST document using TCPDF * @package com.tecnick.tcpdf * @abstract TCPDF - Example: Default Header and Footer * @author Nicola Asuni * @since 2008-03-04 */ // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Guadalajara'); $pdf->SetTitle('Formato Guadalajara'); $pdf->SetSubject('Formatos Espacios Abiertos'); $pdf->SetKeywords('Guadalajara, centro_historico'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '', '', array(91, 104, 113), array(91, 104, 113)); $pdf->setFooterData(array(91, 104, 113), array(91, 104, 113)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('times', '', 14, '', true); // INICIA FORMATO DE DECLARACIÓN PERSONA FÍSICA $pdf->AddPage(); $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); $html = <<<EOD <br> <h1>titulo</h1> <p style="text-align: right;">texto</p> <br> <br> EOD; $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // TERMINA FORMATO DE DECLARACIÓN PERSONA FÍSICA // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output('formatos_guadalajara.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+ }
public function downAction() { $translate = Zend_Registry::get('Zend_Translate'); $this->view->title = 'In lương - ' . $translate->_('TEXT_DEFAULT_TITLE'); $this->view->headTitle($this->view->title); $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED; $option = array('layout' => '1_column/layout', 'layoutPath' => $layoutPath); Zend_Layout::startMvc($option); $date = time(); $thang = $this->_getParam('thang', date('m', $date)); $nam = $this->_getParam('nam', date('Y', $date)); $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); $em_id = $identity->em_id; $emModel = new Front_Model_Employees(); $em_info = $emModel->fetchRow("em_id={$em_id}"); $khenthuongModel = new Front_Model_KhenThuong(); $khen_thuong = $khenthuongModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59"); $kyluatModel = new Front_Model_KyLuat(); $ky_luat = $kyluatModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59"); $bangluongModel = new Front_Model_BangLuong(); $bang_luong = $bangluongModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59"); if (!$em_info || !$bang_luong) { $this->_helper->viewRenderer->setRender('loi'); } else { $luong_toi_thieu = $bang_luong->bl_luong_toi_thieu; $giai_doan = $bang_luong->bl_giai_doan; $loai_luong = $bang_luong->bl_loai_luong; $luong_thu_viec = $bang_luong->bl_luong_thu_viec; $he_so_luong = $bang_luong->bl_hs_luong; $bhxh = $bang_luong->bl_bhxh; $bhyt = $bang_luong->bl_bhyt; $hs_pc_chuc_vu = $bang_luong->bl_hs_pc_cong_viec; $hs_pc_trach_nhiem = $bang_luong->bl_hs_pc_trach_nhiem; $hs_pc_khu_vuc = $bang_luong->bl_hs_pc_khu_vuc; $hs_pc_tnvk_phan_tram = $bang_luong->bl_hs_pc_tnvk; $tham_nien = $bang_luong->bl_tham_nien; $uu_dai_nghe = $bang_luong->bl_hs_pc_udn; $cong_vu = $bang_luong->bl_hs_pc_cong_vu; $kiem_nhiem = $bang_luong->bl_pc_kiem_nhiem; $hs_pc_khac = $bang_luong->bl_hs_pc_khac; $he_so_tang_them = $bang_luong->bl_pc_tang_them; $hs_pc_khac_type = $bang_luong->bl_pc_khac_type; $hs_pc_thu_hut_phan_tram = $bang_luong->bl_pc_thu_hut; $phan_loai = strtoupper($bang_luong->bl_phan_loai); $phan_loai_he_so = $bang_luong->bl_phan_loai_he_so; $luong_toi_thieu_sau_bh = (int) ($luong_toi_thieu * (100 - ($bhxh + $bhyt)) / 100); $luong_toi_thieu_bhyt = (int) ($luong_toi_thieu * (100 - $bhyt) / 100); $pc_trach_nhiem = $pc_cong_vu = $pc_khac = $pc_kiem_nhiem = $pc_uu_dai_nghe = $luong_toi_thieu; $pc_chuc_vu = $pc_tnvk = $pc_thu_hut = $pc_tham_nien = $luong_toi_thieu_sau_bh; $pc_khu_vuc = $luong_toi_thieu_bhyt; $thanh_tien_hsl = $luong_toi_thieu_sau_bh * $he_so_luong * $phan_loai_he_so; //if ($this->he_so->eh_giai_doan) //$hs_pc_chuc_vu = number_format ($this->he_so->eh_pc_cong_viec*(100-$luong_thu_viec)/100, 2); $thanh_tien_pc_chuc_vu = $hs_pc_chuc_vu * $pc_chuc_vu * $phan_loai_he_so; //if ($this->he_so->eh_giai_doan) //$hs_pc_trach_nhiem = number_format ($this->he_so->eh_pc_trach_nhiem*(100-$luong_thu_viec)/100, 2); $thanh_tien_pc_trach_nhiem = $hs_pc_trach_nhiem * $pc_trach_nhiem * $phan_loai_he_so; //if ($this->he_so->eh_giai_doan) //$hs_pc_khu_vuc = number_format ($this->he_so->eh_pc_kv*(100-$luong_thu_viec)/100, 2); $thanh_tien_pc_khu_vuc = $hs_pc_khu_vuc * $pc_khu_vuc * $phan_loai_he_so; $hs_pc_tnvk = ($he_so_luong + $hs_pc_chuc_vu) * $hs_pc_tnvk_phan_tram / 100; //if ($this->he_so->eh_giai_doan) //$hs_pc_tnvk = number_format ($hs_pc_tnvk*(100-$luong_thu_viec)/100, 2); $thanh_tien_pc_tham_nien_vuot_khung = $hs_pc_tnvk * $pc_tnvk * $phan_loai_he_so; $hs_pc_tham_nien = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_trach_nhiem) * $tham_nien / 100 * 100) / 100; $thanh_tien_pc_tham_nien = $hs_pc_tham_nien * $pc_tham_nien * $phan_loai_he_so; $hs_pc_thu_hut = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $hs_pc_thu_hut_phan_tram / 100 * 100) / 100; $thanh_tien_pc_thu_hut = $hs_pc_thu_hut * $pc_thu_hut * $phan_loai_he_so; $hs_pc_uu_dai_nghe = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $uu_dai_nghe / 100 * 100) / 100; $thanh_tien_pc_uu_dai_nghe = $hs_pc_uu_dai_nghe * $pc_uu_dai_nghe * $phan_loai_he_so; $hs_pc_cong_vu = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $cong_vu / 100 * 100) / 100; $thanh_tien_pc_cong_vu = $hs_pc_cong_vu * $pc_cong_vu * $phan_loai_he_so; $hs_pc_kiem_nhiem = floor(($he_so_luong + $hs_pc_chuc_vu + $hs_pc_tnvk) * $kiem_nhiem / 100 * 100) / 100; $thanh_tien_pc_kiem_nhiem = $hs_pc_kiem_nhiem * $pc_kiem_nhiem * $phan_loai_he_so; $thanh_tien_pc_khac = $hs_pc_khac * $pc_khac; $hs_pc_khac_he_so = $hs_pc_khac; if ($hs_pc_khac_type) { $thanh_tien_pc_khac = $thanh_tien_pc_khac / 100; $hs_pc_khac_he_so = $hs_pc_khac / 100; } $thanh_tien_pc_khac = $thanh_tien_pc_khac * $phan_loai_he_so; $tong_1 = (int) ($thanh_tien_pc_thu_hut + $thanh_tien_hsl + $thanh_tien_pc_chuc_vu + $thanh_tien_pc_trach_nhiem + $thanh_tien_pc_khu_vuc + $thanh_tien_pc_tham_nien_vuot_khung + $thanh_tien_pc_tham_nien + $thanh_tien_pc_uu_dai_nghe + $thanh_tien_pc_cong_vu + $thanh_tien_pc_kiem_nhiem); $hs_tang_them = $hs_pc_thu_hut + $he_so_luong + $hs_pc_chuc_vu + $hs_pc_trach_nhiem + $hs_pc_khu_vuc + $hs_pc_tnvk + $hs_pc_tham_nien + $hs_pc_uu_dai_nghe + $hs_pc_cong_vu + $hs_pc_kiem_nhiem + $hs_pc_khac_he_so; $ti_le_tang_them = ($hs_tang_them - $hs_pc_kiem_nhiem) * $luong_toi_thieu * $he_so_tang_them * $phan_loai_he_so; $tong_2 = (int) $tong_1 + $ti_le_tang_them; $tong_khen_thuong = 0; if (sizeof($khen_thuong)) { foreach ($khen_thuong as $kt) { $tong_khen_thuong += $kt->kt_money; } } $tong_khien_trach = 0; if (sizeof($ky_luat)) { foreach ($ky_luat as $kl) { $tong_khien_trach += $kl->kl_money; } } $tong_cong = $tong_2 + $tong_khen_thuong - $tong_khien_trach; //$mpdf = new mPDF(); $khen_thuong_text_out = ' <tr> <td colspan="3" class="tieu-de">Khen thưởng</td> </tr> <tr> <td colspan="3"> <br/> <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true"> <tr> <td style="width: 36pt;"><strong>#</strong></td> <td><strong>Ngày</strong></td> <td style="width: 235pt;"><strong>Lý do</strong></td> <td style="width: 100pt;"><strong>Mức thưởng</strong></td> </tr>'; if (sizeof($khen_thuong)) { $i = 0; foreach ($khen_thuong as $kt) { $i++; $khen_thuong_text_out .= '<tr> <td>' . $i . '</td> <td>' . date('d-m-Y', strtotime($kt->kt_date)) . '</td> <td>' . $kt->kt_ly_do . '</td> <td>' . number_format($kt->kt_money, 0, '.', ',') . '</td> </tr>'; } } else { $khen_thuong_text_out .= '<tr><td colspan="4">Không có khen thưởng nào!</td></tr>'; } $khen_thuong_text_out .= ' <tr> <td colspan="3"><strong>Tổng cộng (III)</strong></td> <td><strong>' . number_format($tong_khen_thuong, 0, '.', ',') . '</strong></td> </tr> </table> </td> </tr>'; $ky_luat_text_out = ' <tr> <td colspan="3" class="tieu-de">Kỷ luật/Khiển trách</td> </tr> <tr> <td colspan="3"> <br/> <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true"> <tr> <td style="width: 36pt;"><strong>#</strong></td> <td><strong>Ngày</strong></td> <td style="width: 235pt;"><strong>Lý do</strong></td> <td style="width: 100pt;"><strong>Mức phạt</strong></td> </tr>'; if (sizeof($ky_luat)) { $i = 0; foreach ($ky_luat as $kl) { $i++; $ky_luat_text_out .= '<tr> <td>' . $i . '</td> <td>' . date('d-m-Y', strtotime($kl->kl_date)) . '</td> <td>' . $kl->kl_ly_do . '</td> <td>' . number_format($kl->kl_money, 0, '.', ',') . '</td> </tr>'; } } else { $ky_luat_text_out .= '<tr><td colspan="4">Không có kỷ luật/khiển trách nào nào!</td></tr>'; } $ky_luat_text_out .= ' <tr> <td colspan="3"><strong>Tổng cộng (IV)</strong></td> <td><strong>' . number_format($tong_khien_trach, 0, '.', ',') . '</strong></td> </tr> </table> </td> </tr>'; $text_outout = ' <style> .ten-co-quan { color: #000; font-size: 10pt; height: 50px; text-align:center; } .ten-bang-luong{ height: 30px; text-align:center; font-size: 10pt; } table.first { color: #003300; font-family: helvetica; font-size: 8pt; border-left: 3px solid red; border-right: 3px solid #FF00FF; border-top: 3px solid green; border-bottom: 3px solid blue; background-color: #ccffcc; } .borders { border: 1px solid #000; font-size: 10px; } .tieu-de{ height: 20px; font-size: 11px; } .noi-dung{ font-size: 10px; } td.second { border: 2px dashed green; } .lowercase { text-transform: lowercase; } .uppercase { text-transform: uppercase; } .capitalize { text-transform: capitalize; } </style> <table width="100%"> <tr> <td width="200" class="ten-co-quan uppercase"> TỔNG CỤC HẢI QUAN <div><strong>CỤC HẢI QUAN HÀ TĨNH</strong></div> </td> <td colspan="2"> </td> </tr> <tr> <td colspan="3" class="ten-bang-luong uppercase">BẢNG LƯƠNG THÁNG ' . $thang . '-' . $nam . '</td> </tr> <tr> <td colspan="3" class="tieu-de">Thông tin cá nhân</td> </tr> <tr> <td colspan="3"> <br/> <table border="1" class="noi-dung" cellpadding="5" nobr="true"> <tr> <td style="width: 120pt;"><strong>Họ tên</strong></td> <td style="width: 80pt;"><strong>Giới tính</strong></td> <td style="width: 100pt;"><strong>Ngày sinh</strong></td> <td style="width: 100pt;"><strong>Phòng ban</strong></td> <td style="width: 96pt;"><strong>Chức vụ</strong></td> </tr> <tr> <td>' . $em_info->em_ho . ' ' . $em_info->em_ten . '</td> <td>' . ($em_info->em_gioi_tinh ? 'Nam' : 'Nữ') . '</td> <td>' . date('d-m-Y', strtotime($em_info->em_ngay_sinh)) . '</td> <td>' . $this->view->viewGetPhongBanName($em_info->em_phong_ban) . '</td> <td>' . $this->view->viewGetChucVuName($em_info->em_chuc_vu) . '</td> </tr> </table> </td> </tr> <tr> <td colspan="3" class="tieu-de"></td> </tr> <tr> <td colspan="3" class="tieu-de">Thông số lương cơ bản</td> </tr> <tr> <td colspan="3"> <br /> <table border="1" width="575pt" class="noi-dung" cellpadding="5" nobr="true"> <tr> <td><strong>Lương cơ bản</strong></td> ' . ($giai_doan ? '<td><strong>Thử việc</strong></td> ' : '') . ' <td style="width: 70pt;"><strong>BHXH</strong></td> <td style="width: 70pt;"><strong>BHYT</strong></td> <td style="width: 210pt;"><strong>Đã trừ BHXH+BHYT</strong></td> </tr> <tr> <td>' . number_format($luong_toi_thieu, 0, '.', ',') . '</td> ' . ($giai_doan ? '<td>' . $luong_thu_viec . '%</td> ' : '') . ' <td>' . $bhxh . '%</td> <td>' . $bhyt . '%</td> <td> Đã trừ BHYT + BHXH: ' . number_format($luong_toi_thieu_sau_bh, 0, '.', ',') . ' <br> Đã trừ BHYT: ' . number_format($luong_toi_thieu_bhyt, 0, '.', ',') . ' </td> </tr> </table> </td> </tr> <tr> <td colspan="3" class="tieu-de"></td> </tr> <tr> <td colspan="3" class="tieu-de">Bảng lương</td> </tr> <tr> <td colspan="3"> <br/> <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true"> <tr> <td style="width: 150pt;"><strong>Tên</strong></td> <td style="width: 245pt;" colspan="2"><strong>Hệ số</strong></td> <td style="width: 100pt;"><strong>Thành tiền</strong></td> </tr> <tr> <td>Kết quả phân loại tháng</td> <td> ' . $phan_loai . ' </td> <td> ' . $phan_loai_he_so . '</td> <td></td> </tr> <tr> <td>Hệ số lương</td> <td colspan="2">' . $he_so_luong . '</td> <td>' . number_format($thanh_tien_hsl, 0, '.', ',') . '</td> </tr> <tr> <td>PC chức vụ</td> <td colspan="2">' . $hs_pc_chuc_vu . '</td> <td>' . number_format($thanh_tien_pc_cong_viec, 0, '.', ',') . '</td> </tr> <tr> <td>PC trách nhiệm</td> <td colspan="2">' . $hs_pc_trach_nhiem . '</td> <td>' . number_format($thanh_tien_pc_trach_nhiem, 0, '.', ',') . '</td> </tr> <tr> <td>PC khu vực</td> <td colspan="2">' . $hs_pc_khu_vuc . '</td> <td>' . number_format($thanh_tien_pc_khu_vuc, 0, '.', ',') . '</td> </tr> <tr> <td>PC thu hút</td> <td>' . $hs_pc_thu_hut_phan_tram . '%</td> <td>' . $hs_pc_thu_hut . '</td> <td>' . number_format($thanh_tien_pc_thu_hut, 0, '.', ',') . '</td> </tr> <tr> <td>PC thâm niên vượt khung</td> <td>' . $hs_pc_tnvk_phan_tram . '%</td> <td>' . $hs_pc_tnvk . '</td> <td>' . number_format($thanh_tien_pc_tham_nien_vuot_khung, 0, '.', ',') . '</td> </tr> <tr> <td>PC thâm niên</td> <td>' . $tham_nien . ' Năm</td> <td>' . $hs_pc_tham_nien . '</td> <td>' . number_format($thanh_tien_pc_tham_nien, 0, '.', ',') . '</td> </tr> <tr> <td>PC ưu đãi nghề</td> <td>' . $uu_dai_nghe . '%</td> <td>' . $hs_pc_uu_dai_nghe . '</td> <td>' . number_format($thanh_tien_pc_uu_dai_nghe, 0, '.', ',') . '</td> </tr> <tr> <td>PC công vụ</td> <td>' . $cong_vu . '%</td> <td>' . $hs_pc_cong_vu . '</td> <td>' . number_format($thanh_tien_pc_cong_vu, 0, '.', ',') . '</td> </tr> <tr> <td>PC kiêm nhiệm</td> <td colspan="2">' . $hs_pc_kiem_nhiem . '</td> <td>' . number_format($thanh_tien_pc_kiem_nhiem, 0, '.', ',') . '</td> </tr> <tr> <td>PC khác</td> <td colspan="2">' . $hs_pc_khac . ($hs_pc_khac_type ? '%' : '') . '</td> <td>' . number_format($thanh_tien_pc_khac, 0, '.', ',') . '</td> </tr> <tr> <td colspan="3">Tổng cộng (I)</td> <td>' . number_format($tong_1, 0, '.', ',') . '</td> </tr> <tr> <td>Tỷ lệ tăng thêm</td> <td colspan="2">' . $hs_tang_them . '</td> <td>' . number_format($ti_le_tang_them, 0, '.', ',') . '</td> </tr> <tr> <td colspan="3"><strong>Tổng cộng (II)</strong></td> <td><strong>' . number_format($tong_2, 0, '.', ',') . '</strong></td> </tr> </table> </td> </tr> <tr> <td colspan="3" class="tieu-de"></td> </tr> ' . $khen_thuong_text_out . ' <tr> <td colspan="3" class="tieu-de"></td> </tr> ' . $ky_luat_text_out . ' <tr> <td colspan="3" class="tieu-de"></td> </tr> <tr> <td colspan="3"> <br/> <table border="1" width="100%" class="noi-dung" cellpadding="5" nobr="true"> <tr> <td style="width: 395pt;"><strong>Tổng được nhận = II + III + IV</strong></td> <td style="width: 100pt;"><strong>' . number_format($tong_cong, 0, '.', ',') . '</strong></td> </tr> </table> </td> </tr> </table> '; /* $mpdf->WriteHTML($text_outout); $file_name = $this->loc_tieng_viet($em_info->em_ho) . '_' . $this->loc_tieng_viet($em_info->em_ten) . '_' . $thang . '-' . $nam . '.pdf'; $mpdf->Output($file_name, 'D'); */ $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(PDF_AUTHOR); $pdf->SetTitle(PDF_HEADER_TITLE); $pdf->SetSubject(PDF_HEADER_TITLE); $pdf->SetKeywords('bang luong'); $pdf->setPrintHeader(false); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setFontSubsetting(true); $pdf->SetFont('dejavusans', '', 14, '', true); $pdf->AddPage(); $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); $file_name = $this->loc_tieng_viet($em_info->em_ho) . '_' . $this->loc_tieng_viet($em_info->em_ten) . '_' . $thang . '-' . $nam . '.pdf'; $pdf->writeHTMLCell(0, 0, '', '', $text_outout, 0, 1, 0, true, '', true); // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output($file_name, 'I'); die; } }
public function actionPDF() { $session = new CHttpSession(); $session->open(); if (isset($session['orderVariations']) && is_array($session['orderVariations']) && count($session['orderVariations']) > 0) { require_once Yii::getPathOfAlias('webroot.protected.extensions.pdf.tcpdf') . DIRECTORY_SEPARATOR . 'tcpdf.php'; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $aOrderVariations = $session['orderVariations']; $html_output = '<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><table>'; $html_output .= '<tr><td colspan="3"></td></tr>'; $html_output .= '<tr><td colspan="3">' . Yii::t('strings', 'Order products:') . "</td></tr>"; $html_output .= '<tr><td colspan="3"></td></tr>'; foreach ($aOrderVariations as $variation_id) { $Product2variation = Product2variation::model()->find('variation_id=' . $variation_id); if (isset($Product2variation)) { $product = ProductDescription::model()->find('product_id=' . $Product2variation['product_id'] . ' AND language_id=' . $this->language_id); $Variation = Variation::model()->find('variation_id=' . $variation_id); $VariationDescription = VariationDescription::model()->find('variation_id=' . $variation_id . ' AND language_id=' . $this->language_id); $html_output .= '<tr><td colspan="3">' . $product['product_name'] . '</td></tr>'; $html_output .= '<tr><td><img src="' . Yii::app()->request->getBaseUrl(true) . '/uploads/images/' . $Variation['variation_image'] . '" alt="product_image" width="100" height="50"/></td>'; $html_output .= '<td>' . $VariationDescription['variation_name'] . '<br/>' . $VariationDescription['variation_description'] . "</td></tr>"; $html_output .= '<tr><td colspan="3"></td><td></td></tr>'; } } $html_output .= '</table></body></html>'; $pdf->SetHeaderData(PDF_HEADER_LOGO, '', '', '', array(0, 64, 255), array(169, 172, 182)); $pdf->setFooterData($tc = array(0, 64, 0), $lc = array(0, 64, 128)); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->setFontSubsetting(true); $pdf->SetFont('dejavusans', '', 14, '', true); $pdf->AddPage(); $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html_output, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = 'L', $autopadding = true); $pdf->Output('order.pdf', 'I'); } }
* @author Nicola Asuni * @since 2008-03-04 */ // Include the main TCPDF library (search for installation path). require_once 'tcpdf_include.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(false); $pdf->setFooterData(false); // set header and footer fonts //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l);
/** Creates a PDF for the Message * */ private function createPdf($user, $uid) { require_once PATH_INCLUDE . '/pdf/tcpdf/config/lang/ger.php'; require_once PATH_INCLUDE . '/pdf/tcpdf/tcpdf.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('LeG Uelzen'); $pdf->SetKeywords(''); // set default header data $pdf->SetHeaderData('../../../res/images/logo.jpg', 15, 'LeG Uelzen', "Abmeldung von: " . $user['forename'] . " " . $user['name'] . " (geb. am " . $user['birthday'] . ")\nKlasse: " . $user['class'], array(0, 0, 0), array(0, 0, 0)); $pdf->setFooterData($tc = array(0, 0, 0), $lc = array(0, 0, 0)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('helvetica', '', 11, '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); // set text shadow effect $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); // Set some content to print $html = '<p align="center"><h2>Rückgabe der LeG-Card / Löschung der Benutzerdaten</h2></p><br>' . 'Hiermit wird bestätigt, dass die Schulbücher von ' . $user['forename'] . ' ' . $user['name'] . ' vollständig zurückgegeben wurden. <br/> Hiermit wird bestätigt, dass sämtliche personenbezogenen Daten am ' . date("d.m.Y") . ' aus dem System gelöscht wurden.<br/>'; if ($user['credit'] == "0.00") { $html .= 'Es liegt kein Restguthaben vor.<br/>'; } else { $html .= 'Es liegt ein Restguthaben in Höhe von ' . $user['credit'] . ' € vor. Dieses muss beim Caterer abgeholt werden.<br/>'; } $html .= 'Mit der Rückgabe der LeG-Card kann das Pfandgeld in Höhe von 3,50 € zzgl. 0,50 €, je nach Zustand der Hülle, ausbezahlt werden.<br/> Dieses Schreiben wurde maschinell erstellt und ist ohne Unterschrift gültig. <hr> <p align="center"><h3>Auszahlung des Restguthabens</h3></p><br> Restguthaben in Höhe von ' . $user['credit'] . ' € am ___.___.2013 ausgezahlt.<br><br> <br> Unterschrift Caterer <br> <hr> <p align="center"><h3>Abschnitt für den Caterer</h3></p><br> Restguthaben in Höhe von ' . $user['credit'] . ' € am ___.___.2013 erhalten.<br><br> <br><br>Unterschrift ' . $user['forename'] . ' ' . $user['name'] . ' (geb. am ' . $user['birthday'] . ') <hr> <p align="center"><h3>Pfanderstattung</h3></p><br> Bitte geben Sie diesen Abschnitt im Gnissel-Büro im Lessing-Gymnasium ab.<br> Bitte kreuzen Sie an, ob Sie den Pfandbetrag an die Schülergenossenschaft Gnissel des LeG Uelzen spenden möchten oder eine Überweisung auf ein Bankkonto wünschen.<br> [ ] Das Pfandgeld möchte ich an Gnissel spenden<br> [ ] Ich möchte das Pfandgeld auf folgendes Konto überwiesen haben:<br> Kontoinhaber: <br> Kontonummer:<br> BLZ: <br> Kreditinstitut: <br><br> Uelzen, den ___.___.2013 Unterschrift ' . $user['forename'] . ' ' . $user['name'] . ' (geb. am ' . $user['birthday'] . ')<br> '; // Print text using writeHTMLCell() $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true); // --------------------------------------------------------- if (!is_dir('../include/pdf/tempPdf')) { mkdir('../include/pdf/tempPdf'); } // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output('../include/pdf/tempPdf/deleted_' . $uid . '.pdf', 'F'); return true; }
function print_pdf($title, $html_content, $lp, $fsize) { global $root; ob_clean(); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $usr = $root->query("SELECT `Emri`,`Mbiemri` FROM administrata WHERE User = '******'username'] . "'"); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor($usr[0]['Emri'] . " " . $usr[0]['Mbiemri']); $pdf->SetTitle($title); $pdf->SetSubject($title); $pdf->SetKeywords($title); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('helvetica', '', $fsize, '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage($lp, 'A4'); // set text shadow effect $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); // Set some content to print $html = <<<EOD {$html_content} EOD; // Print text using writeHTMLCell() $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output('example_001.pdf', 'I'); ob_end_clean(); //============================================================+ // END OF FILE //============================================================+ }
/** * 设置PDF文件 */ function pdf_four() { //包含类文件 require_once 'tcpdf.php'; //创建TCPDF对象 //PDF_PAGE_ORIENTATION: 页面方向横向P纵向L,默认P //PDF_UNIT: 档的最小度量单位,点pt/毫米mm/厘米cm/英寸in。(默认为mm) //PDF_PAGE_FORMAT: 设置 PDF 页面格式,默认为 A4 纸 //True:是否为唯一编码格式,true 为是 //编码格式 //最后一个参数是:确定是否需要磁盘高速缓存,默认为否 //false=PDF/X true=PDF/A $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, false); //设置文档信息 $pdf->SetCreator('*****@*****.**'); $pdf->SetAuthor('Leju'); $pdf->SetTitle('标题TCPDF'); $pdf->SetSubject('这是一个生成PDF文件简单的例子'); $pdf->SetKeywords('TCPDF, PDF, example, 测试, guide'); //设置页眉和页脚数据 //204,255,51 绿色 //255,51,102 红色 $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'TCPDF header info111', 'www.leju.com', array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); //设置页眉和页脚字体 $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); //设置间距 //PDF_MARGIN_LEFT 左边距 //PDF_MARGIN_TOP 顶部距离 //PDF_MARGIN_RIGHT 右边距 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); //头部上边距 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); //脚部下边距 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //设置自动页面中断 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //设置默认字体子集模式, 嵌入字体 $pdf->setFontSubsetting(true); //设置字体 //dejavusans 是 UTF-8 编码字体, 如果你需要输出标准的ASCII字符,你可以使用 //helvetica 或者 times 减小文件的体积. $pdf->SetFont('dejavusans', '', 14, '', true); //添加页面 $pdf->AddPage(); //设置文字阴影效果 $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.8, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); //内容部分 $html = ' <h1> Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;"> <span style="color:black;">TC</span><span style="color:white;">PDF</span> </a>!</h1> <i>This is the first example of TCPDF library.</i> <p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p> <p>Please check the source code documentation and other examples for further information.</p> <p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>'; //生成内容 $pdf->writeHTML($html); //输出内容 $pdf->Output('example.pdf', 'I'); }
/** * Output the contents of a wiki page as a PDF * * Based on work submitted by Steven Maus <*****@*****.**> (2014) * * @return void */ public function pdfTask() { // Does a page exist for the given pagename? if (!$this->page->exists() || $this->page->isDeleted()) { App::abort(404, Lang::txt('COM_WIKI_WARNING_NOT_FOUND')); // No! Ask if they want to create a new page /*$this->view->setLayout('doesnotexist'); if ($this->_group) { $this->page->set('group_cn', $this->_group); $this->page->set('scope', $this->_group . '/wiki'); } if ($this->getError()) { foreach ($this->getErrors() as $error) { $this->view->setError($error); } } $this->view->display(); return;*/ } // Retrieve a specific version if given $this->view->revision = $this->page->revision(Request::getInt('version', 0)); if (!$this->view->revision->exists()) { foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->set('page', $this->page)->setLayout('nosuchrevision')->display(); return; } Request::setVar('format', 'pdf'); $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(10); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // Set font $pdf->SetFont('dejavusans', '', 11, '', true); $pdf->setAuthor = $this->page->creator('name'); $pdf->setCreator = \Config::get('sitename'); $pdf->setDocModificationTimeStamp($this->page->modified()); $pdf->setHeaderData(NULL, 0, strtoupper($this->page->get('itle')), NULL, array(84, 94, 124), array(146, 152, 169)); $pdf->setFooterData(array(255, 255, 255), array(255, 255, 255)); $pdf->AddPage(); // Set the view page content to current revision html $this->view->page = $this->page; // Load the wiki parser $wikiconfig = array('option' => $this->_option, 'scope' => $this->page->get('scope'), 'pagename' => $this->page->get('pagename'), 'pageid' => $this->page->get('id'), 'filepath' => '', 'domain' => $this->page->get('group_cn')); $p = Parser::getInstance(); // Parse the text $this->view->revision->set('pagehtml', $p->parse($this->view->revision->get('pagetext'), $wikiconfig, true, true)); $pdf->writeHTML($this->view->loadTemplate(), true, false, true, false, ''); header("Content-type: application/octet-stream"); // Close and output PDF document // Force the download of the PDF $pdf->Output($this->page->get('pagename') . '.pdf', 'D'); exit; }
* @since 2008-03-04 */ session_start(); require_once 'config/lang/eng.php'; require_once 'tcpdf.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(''); $pdf->SetTitle(''); $pdf->SetSubject(''); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' ', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData($tc = array(0, 64, 0), $lc = array(0, 64, 128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l);
<?php require_once 'tcpdf_include.php'; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Uitgaanscentrum de Bonte Koe'); $pdf->SetTitle('E-Ticket'); $pdf->SetSubject('Bioscoop ticket'); $pdf->SetKeywords('De Bonte Koe, Uitgaan, Bioscoop, ticket'); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(255, 165, 0), array(0, 0, 255)); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterData(array(255, 165, 0), array(0, 0, 255)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // --------------------------------------------------------- $pdf->setFontSubsetting(true); $pdf->SetFont('dejavusans', '', 11, '', true); $pdf->AddPage(); $html = <<<EOD <br /><h1>E-ticket</h1> <p> Dank voor uw reservering bij uitgaanscentrum de bonte koe.</p> <p style="font-style:italic;background-color:#CC0000;color:white;text-align:center;"> Print dit ticket uit en neem deze mee bij uw bioscoopbezoek!</p> EOD; $pdf->writeHTMLCell(0, 0, '', '40', $html, array('LTRB' => array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))), 1, 0, true, '', true); $pdf->Image('../../images/bioscoopzaal.jpg', '', '100', 100, 50, '', '', 'T', false, 300, 'C', false, false, 1, false, false, false); // --------------------------------------------------------- $pdf->Output('tickets.pdf', 'I');
/** * Generate a receipt * * @return void */ public function receiptTask() { // Incoming $id = Request::getInt('id', 0); // Load the order $row = new Order($this->database); $row->load($id); // Instantiate an OrderItem object $oi = new OrderItem($this->database); if ($id) { // Get order items $orderitems = $oi->getOrderItems($id); if ($orderitems) { foreach ($orderitems as $r) { $params = new Registry($r->params); $selections = new Registry($r->selections); // Get size selection $r->sizes = $params->get('size', ''); $r->sizes = str_replace(' ', '', $r->sizes); $r->selectedsize = trim($selections->get('size', '')); $r->sizes = preg_split('/,/', $r->sizes); $r->sizeavail = in_array($r->selectedsize, $r->sizes) ? 1 : 0; // Get color selection $r->colors = $params->get('color', ''); $r->colors = str_replace(' ', '', $r->colors); $r->selectedcolor = trim($selections->get('color', '')); $r->colors = preg_split('/,/', $r->colors); } } else { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('Order empty, cannot generate receipt'), 'error'); return; } $customer = User::getInstance($row->uid); } else { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('Need order ID to issue a receipt'), 'error'); return; } // Include needed libraries // require_once(JPATH_COMPONENT . DS . 'helpers' . DS . 'receipt.pdf.php'); // Build the link displayed $sef = Route::url('index.php?option=' . $this->_option); if (substr($sef, 0, 1) == '/') { $sef = substr($sef, 1, strlen($sef)); } $webpath = str_replace('/administrator/', '/', Request::base() . $sef); $webpath = str_replace('//', '/', $webpath); if (isset($_SERVER['HTTPS'])) { $webpath = str_replace('http:', 'https:', $webpath); } if (!strstr($webpath, '://')) { $webpath = str_replace(':/', '://', $webpath); } //require_once(PATH_CORE . DS . 'libraries/tcpdf/tcpdf.php'); $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $receipt_title = $this->config->get('receipt_title') ? $this->config->get('receipt_title') : 'Your Order'; $hubaddress = array(); $hubaddress[] = $this->config->get('hubaddress_ln1') ? $this->config->get('hubaddress_ln1') : ''; $hubaddress[] = $this->config->get('hubaddress_ln2') ? $this->config->get('hubaddress_ln2') : ''; $hubaddress[] = $this->config->get('hubaddress_ln3') ? $this->config->get('hubaddress_ln3') : ''; $hubaddress[] = $this->config->get('hubaddress_ln4') ? $this->config->get('hubaddress_ln4') : ''; $hubaddress[] = $this->config->get('hubaddress_ln5') ? $this->config->get('hubaddress_ln5') : ''; $hubaddress[] = $this->config->get('hubemail') ? $this->config->get('hubemail') : ''; $hubaddress[] = $this->config->get('hubphone') ? $this->config->get('hubphone') : ''; $headertext_ln1 = $this->config->get('headertext_ln1') ? $this->config->get('headertext_ln1') : ''; $headertext_ln2 = $this->config->get('headertext_ln2') ? $this->config->get('headertext_ln2') : Config::get('sitename'); $footertext = $this->config->get('footertext') ? $this->config->get('footertext') : 'Thank you for contributions to our HUB!'; $receipt_note = $this->config->get('receipt_note') ? $this->config->get('receipt_note') : ''; // Get front-end template name $sql = "SELECT template FROM `#__template_styles` WHERE `client_id`=0 AND `home`=1"; $this->database->setQuery($sql); $tmpl = $this->database->loadResult(); // set default header data $pdf->SetHeaderData(NULL, 0, strtoupper($receipt_title) . ' - #' . $id, NULL, array(84, 94, 124), array(146, 152, 169)); $pdf->setFooterData(array(255, 255, 255), array(255, 255, 255)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(10); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // Set font $pdf->SetFont('dejavusans', '', 11, '', true); $pdf->AddPage(); // HTML content $this->view->setLayout('receipt'); $this->view->hubaddress = $hubaddress; $this->view->headertext_ln1 = $headertext_ln1; $this->view->headertext_ln2 = $headertext_ln2; $this->view->receipt_note = $receipt_note; $this->view->receipt_title = $receipt_title; $this->view->option = $this->_option; $this->view->url = $webpath; $this->view->customer = $customer; $this->view->row = $row; $this->view->orderitems = $orderitems; $html = $this->view->loadTemplate(); // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); // --------------------------------------------------------- $dir = PATH_APP . DS . 'site' . DS . 'store' . DS . 'temp'; $tempFile = $dir . DS . 'receipt_' . $id . '.pdf'; if (!is_dir($dir)) { if (!\Filesystem::makeDirectory($dir)) { throw new Exception(Lang::txt('Failed to create folder to store receipts'), 500); } } // Close and output PDF document $pdf->Output($tempFile, 'F'); if (is_file($tempFile)) { $xserver = new Server(); $xserver->filename($tempFile); $xserver->serve_inline($tempFile); exit; } else { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('There was an error creating a receipt'), 'error'); return; } return; }
function pdf($html = null, $logo = null, $nombre = null, $estadistica, $itiniere, $transporte) { //$html= utf8_decode($html); // $html="OOOJHKJHKJH JLH KJH KH KJH"; ob_clean(); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, array(210, 272), true, 'UTF-8', false); // $pdf = new TCPDF('P', 'IN', array (8.5,11),true, 'UTF-8', false); // set document information //$pdf->SetCreator(PDF_CREATOR); //$pdf->SetAuthor('Nicola Asuni'); //$pdf->SetTitle('TCPDF Example 001'); //$pdf->SetSubject('TCPDF Tutorial'); //$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data //$pdf->SetHeaderData($logo, '20', PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); if (!empty($logo)) { $pdf->SetHeaderData($logo, '20', '', ' PLAN ESTRATEGICO DE SEGURIDAD VÍAL ' . date('d/m/Y'), array(0, 64, 128), array(0, 64, 128)); } $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // set header and footer fonts // $pdf->SetMargins(23, 35, 13); $pdf->SetMargins(32, 35, 20); $pdf->SetHeaderMargin(14); $pdf->SetFooterMargin(21); $pdf->SetAutoPageBreak(TRUE, 20); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //$pdf->setLanguageArray($l); $pdf->setFontSubsetting(false); $pdf->SetFont('dejavusans', '', 10, '', true); //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', '6')); $pdf->AddPage(); $pdf->writeHTML($html, true, false, true, false, ''); // $pdf->AddPage(); $pdf->SetFillColor(0, 0, 0); $pdf->Write(10, ' ARL'); // echo $estadistica[0]->arlnula;die; // GRAFICA No 1 $xc = $estadistica[0]->arlnula; $yc = $estadistica[0]->arlsi; $r = $estadistica[0]->arlno; //echo "<pre>"; // var_dump($estadistica);die(); $total = $xc + $yc + $r; $r1 = $xc * 360 / $total; $r2 = $yc * 360 / $total; $r3 = $r * 360 / $total; $r1 = round($r1); $r2 = round($r2); $r3 = round($r3); $xc1 = 105; $yc1 = 120; $r11 = 50; $pdf->SetFillColor(0, 0, 255); $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2); $pdf->SetFillColor(0, 255, 0); $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2); $pdf->SetFillColor(255, 0, 0); $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2); $pdf->SetTextColor(0, 0, 255); $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc); $pdf->SetTextColor(0, 255, 0); $pdf->Text(150, 155, 'SI: ' . $yc); $pdf->SetTextColor(255, 0, 0); $pdf->Text(150, 160, 'NO: ' . $r); $pdf->AddPage(); //---------------------------------------------------------------- // GRAFICA No 2 $pdf->SetTextColor(0, 0, 0); $pdf->Write(10, ' PENSION'); $xc = $estadistica[0]->pensionnula; $yc = $estadistica[0]->pensionsi; $r = $estadistica[0]->pensionno; $total = $xc + $yc + $r; $r1 = $xc * 360 / $total; $r2 = $yc * 360 / $total; $r3 = $r * 360 / $total; $r1 = round($r1); $r2 = round($r2); $r3 = round($r3); $xc1 = 105; $yc1 = 100; $r11 = 50; $pdf->SetFillColor(0, 0, 255); $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2); $pdf->SetFillColor(0, 255, 0); $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2); $pdf->SetFillColor(255, 0, 0); $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2); $pdf->SetTextColor(0, 0, 255); $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc); $pdf->SetTextColor(0, 255, 0); $pdf->Text(150, 155, 'SI: ' . $yc); $pdf->SetTextColor(255, 0, 0); $pdf->Text(150, 160, 'NO: ' . $r); $pdf->AddPage(); //---------------------------------------------------------------- // GRAFICA No 3 $pdf->SetTextColor(0, 0, 0); $pdf->Write(10, ' EPS'); $xc = $estadistica[0]->epsnula; $yc = $estadistica[0]->epssi; $r = $estadistica[0]->epsno; $total = $xc + $yc + $r; $r1 = $xc * 360 / $total; $r2 = $yc * 360 / $total; $r3 = $r * 360 / $total; $r1 = round($r1); $r2 = round($r2); $r3 = round($r3); $xc1 = 105; $yc1 = 100; $r11 = 50; $pdf->SetFillColor(0, 0, 255); $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2); $pdf->SetFillColor(0, 255, 0); $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2); $pdf->SetFillColor(255, 0, 0); $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2); $pdf->SetTextColor(0, 0, 255); $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc); $pdf->SetTextColor(0, 255, 0); $pdf->Text(150, 155, 'SI: ' . $yc); $pdf->SetTextColor(255, 0, 0); $pdf->Text(150, 160, 'NO: ' . $r); $pdf->AddPage(); //---------------------------------------------------------------- // GRAFICA No 4 $pdf->SetTextColor(0, 0, 0); $pdf->Write(10, ' CAJA DE COMPENSACIÓN'); $xc = $estadistica[0]->cajacompensacionnula; $yc = $estadistica[0]->cajacompensacionsi; $r = $estadistica[0]->cajacompensacionno; $total = $xc + $yc + $r; $r1 = $xc * 360 / $total; $r2 = $yc * 360 / $total; $r3 = $r * 360 / $total; $r1 = round($r1); $r2 = round($r2); $r3 = round($r3); $xc1 = 105; $yc1 = 100; $r11 = 50; $pdf->SetFillColor(0, 0, 255); $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2); $pdf->SetFillColor(0, 255, 0); $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2); $pdf->SetFillColor(255, 0, 0); $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2); $pdf->SetTextColor(0, 0, 255); $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc); $pdf->SetTextColor(0, 255, 0); $pdf->Text(150, 155, 'SI: ' . $yc); $pdf->SetTextColor(255, 0, 0); $pdf->Text(150, 160, 'NO: ' . $r); $pdf->AddPage(); //---------------------------------------------------------------- // GRAFICA No 5 $pdf->SetTextColor(0, 0, 0); $pdf->Write(10, ' DESPLAZAMIENTO EN MISIÓN'); $xc = $estadistica[0]->usu_desplazamiento_misionnula; $yc = $estadistica[0]->usu_desplazamiento_misionsi; $r = $estadistica[0]->usu_desplazamiento_misionno; $total = $xc + $yc + $r; $r1 = $xc * 360 / $total; $r2 = $yc * 360 / $total; $r3 = $r * 360 / $total; $r1 = round($r1); $r2 = round($r2); $r3 = round($r3); $xc1 = 105; $yc1 = 100; $r11 = 50; $pdf->SetFillColor(0, 0, 255); $pdf->PieSector($xc1, $yc1, $r11, 0, $r1, 'FD', false, 0, 2); $pdf->SetFillColor(0, 255, 0); $pdf->PieSector($xc1, $yc1, $r11, $r1, $r2 + $r1, 'FD', false, 0, 2); $pdf->SetFillColor(255, 0, 0); $pdf->PieSector($xc1, $yc1, $r11, $r2 + $r1, 0, 'FD', false, 0, 2); $pdf->SetTextColor(0, 0, 255); $pdf->Text(150, 150, 'NO CONTESTADAS: ' . $xc); $pdf->SetTextColor(0, 255, 0); $pdf->Text(150, 155, 'SI: ' . $yc); $pdf->SetTextColor(255, 0, 0); $pdf->Text(150, 160, 'NO: ' . $r); // $pdf->Write(0, 'Example of PieSector() method.'); //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); // $pdf->writeHTMLCell(1, 1, '', '', $html, 0, 1, 0, true, '', true); $pdf->Output('pesv.pdf', 'I'); }
function _pdf_create($content = null, $fileName = null) { // create pdf by tcpdf $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetPrintFooter(false); $pdf->SetPrintHeader(false); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setFontSubsetting(true); $pdf->SetFont('times', '', 11, '', true); $pdf->AddPage(); $pdf->writeHTMLCell(0, 0, '', '', $content, 0, 1, 0, true, '', true); $pdf->Output(IMAGE_LOCATION . $fileName . '.pdf', 'F'); }
public function process() { $context = \CADB\Model\Context::instance(); if (!$this->params['nid']) { Error('단체협약서 번호를 입력하세요.'); } if (!$this->themes) { $this->themes = $context->getProperty('service.themes'); } $this->fields = \CADB\Agreement::getFieldInfo(1); $this->articles = \CADB\Agreement::getAgreement($this->params['nid'], $this->params['did'] ? $this->params['did'] : 0); if (!$this->articles) { Error('존재하지 않는 단체협약입니다.'); } \CADB\Log::articleLog('pdf', $this->params['nid'], $this->params['did'] ? $this->params['did'] : 0, "단체협약: [" . $this->articles['subject'] . "]을 PDF 조회했습니다."); $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor($context->getProperty('service.title')); $pdf->SetTitle($this->articles['subject']); $pdf->SetSubject($this->articles['subject']); $pdf->SetKeywords(preg_replace("/[ ]{1,}/i", ", ", $this->article['subject'])); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $context->getProperty('service.title'), $context->getProperty('service.domain'), array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set default font subsetting mode $pdf->setFontSubsetting(true); $pdf->SetFont('nanumbarungothic', '', 14, '', true); $pdf->AddPage(); // set text shadow effect $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); $pdf->writeHTMLCell(0, 0, '', '', '<h1>' . $this->articles['subject'] . '</h1><br><br>', 0, 1, 0, true, '', true); ob_start(); $theme_html_file = ""; if ($this->themes) { $theme_html_file = CADB_PATH . "/themes/" . $this->themes . "/articles/pdf.html.php"; if ($theme_html_file && file_exists($theme_html_file)) { include $theme_html_file; } else { include dirname(__FILE__) . "/pdf.html.php"; } } else { include dirname(__FILE__) . "/pdf.html.php"; } $content = ob_get_contents(); ob_end_clean(); $pdf->SetFont('nanumbarungothic', '', 12, '', true); $pdf->writeHTML($content, true, false, false, false, 'center'); $pdf->SetFont('nanumbarungothic', '', 14, '', true); $pdf->writeHTMLCell(0, 0, '', '', $this->articles['content'], 0, 1, 0, true, '', true); $pdf->Output($this->articles['subject'] . '.pdf', 'I'); }
* @since 2008-03-04 */ // Include the main TCPDF library (search for installation path). require_once 'tcpdf_include.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $fontname = $pdf->addTTFfont('font/arial.ttf', 'TrueTypeUnicode', '', 32); // set document information $pdf->SetCreator('2014 ACP Committee'); $pdf->SetAuthor('2014 ACP Committee'); $pdf->SetTitle('Invitation Letter'); $pdf->SetSubject(''); $pdf->SetKeywords(''); // set default header data $pdf->SetHeaderData('header.jpg', PDF_HEADER_LOGO_WIDTH, '' . '', '', array(255, 255, 255), array(255, 255, 255)); $pdf->setFooterData(array(23, 54, 93), array(255, 255, 255)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array($fontname, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(1); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
* @author Nicola Asuni * @since 2008-03-04 */ // Include the main TCPDF library (search for installation path). require_once 'tcpdf_include.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('FEEDBACK'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 32, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
function now_time_schedule() { $get_data = $this->input->get(); $time = strtotime($get_data['time']); $this->load->model('exhibition_model'); $this->load->model('schedule_model'); //会展网 $where_find_exh = array('id' => $get_data['id']); $data_find_exh = $this->exhibition_model->get_row_array($where_find_exh); if (!empty($data_find_exh)) { $parent_exh_title = $data_find_exh['title']; $begin_time = $data_find_exh['begin_time']; $end_time = $data_find_exh['end_time']; } if (!empty($get_data['cat_id'])) { //子会展的信息 $where_find_schedule_cat = array('id' => $get_data['cat_id']); $data_find_schedule_cat = $this->exhibition_model->get_row_array($where_find_schedule_cat); if (!empty($data_find_schedule_cat)) { $parent_exh_title = $data_find_schedule_cat['title']; $begin_time = $data_find_schedule_cat['begin_time']; $end_time = $data_find_schedule_cat['end_time']; } $where_find_schedule = array('exb_id' => $get_data['cat_id'], 'date_time' => $time, 'order_by' => 'str_time asc'); $data_find_schedule = $this->schedule_model->get_list($where_find_schedule); } else { $where_find_schedule = array('exb_id' => $get_data['id'], 'date_time' => $time, 'order_by' => 'str_time asc'); $data_find_schedule = $this->schedule_model->get_list($where_find_schedule); } if (!empty($data_find_schedule)) { $html_test = ''; foreach ($data_find_schedule as $k3 => $v3) { //判断data_name 类型(上午,中午,下午) if ($v3['date_name'] == 1) { $v3['date_name'] = "上午"; } else { if ($v3['date_name'] == 2) { $v3['date_name'] = "中午"; } else { if ($v3['date_name'] == 3) { $v3['date_name'] = "下午"; } else { if ($v3['date_name'] == 4) { $v3['date_name'] = "晚上"; } } } } $html_test .= '<table border="0" cellspacing="4" cellpadding="2"> <tr> <td></td> <td>' . date('Y-m-d', $v3['date_time']) . ' 日程表</td> </tr> <tr> <td>' . $v3["date_name"] . '</td> <td></td> </tr> <tr> <td bgcolor="#cccccc" width="100px">' . date("H:i", $v3["str_time"]) . " - " . date("H:i", $v3["end_time"]) . '</td> <td bgcolor="#cccccc" width="530px">' . $v3['title'] . '</td> </tr> <tr> <td></td> <td>' . $v3['intro'] . '</td> </tr> <tr> <td></td> <td></td> </tr> </table> <div style="padding:10px;"></div>'; } require_once "./third_part/tcpdf/tcpdf.php"; //实例化 $pdf = new TCPDF('p', 'mm', 'A4', true, 'UTF-8', false); // 设置文档信息 $pdf->SetCreator('Helloweba'); $pdf->SetAuthor('yueguangguang'); $pdf->SetTitle($parent_exh_title); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, PHP'); // 设置页眉和页脚信息 $pdf->SetHeaderData('', 0, $parent_exh_title . ' ' . date('Y-m-d', $begin_time) . ' ~ ' . date('Y-m-d', $end_time), '', array(0, 0, 0), array(0, 0, 0)); $pdf->setFooterData(array(0, 0, 0), array(0, 64, 128)); // 设置页眉和页脚字体 $pdf->setHeaderFont(array('stsongstdlight', '', '10')); $pdf->setFooterFont(array('helvetica', '', '8')); // 设置默认等宽字体 $pdf->SetDefaultMonospacedFont('courier'); // 设置间距 $pdf->SetMargins(15, 27, 15); $pdf->SetHeaderMargin(5); $pdf->SetFooterMargin(2); // 设置分页 $pdf->SetAutoPageBreak(TRUE, 25); // set image scale factor $pdf->setImageScale(1.25); // set default font subsetting mode $pdf->setFontSubsetting(true); //设置字体 $pdf->SetFont('stsongstdlight', '', 12); $pdf->AddPage(); $str1 = $html_test; $pdf->writeHTML($str1, true, false, false, false, 'center'); //$pdf->writeHTMLCell(0, 0, '', '', $str1, 0, 1, 0, true, '', true); //$pdf->Write(0,$str1,'', 0, 'L', true, 0, false, false, 0); $pdf_title = $time . '.pdf'; //输出PDF if (!empty($get_data['type']) && $get_data['type'] == 'stamp') { $pdf->Output($pdf_title); } else { $pdf->Output($pdf_title, 'D'); } } else { _reminder('日程安排是空的,请选择有内容的日程表下载!'); } }
protected function download_pdf($html) { $this->load->library('tcpdf'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } $pdf->setFontSubsetting(true); $pdf->SetFont('dejavusans', '', 14, '', true); $pdf->AddPage(); $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); $pdf->Output('example_001.pdf', 'I'); }
public function make_pdf($order_id, $save_to_file = true) { // 获取订单记录 $order = M('loan_order')->find($order_id); if (!$order) { $this->error = '找不到此订单!'; return false; } $order_id = $order['id']; // 获取用户协议记录 $contract = M('loan_user_contract')->find($order['uid']); if (!$contract) { $this->error = '找不到用户的认证资料!'; return false; } $order_auth = M('loan_order_auth')->where(['order_id' => $order['id']])->getField('auth_id,url'); import('Common.Util.Tcpdf.Tcpdf'); $pdf = new \TCPDF('P', 'MM', 'A4', true, 'UTF-8', false); $pdf->SetCreator('指尖分期'); $pdf->SetAuthor('广西云尚文化产业投资有限公司'); $pdf->SetTitle('指尖分期协议-' . $order['realname'] . '-' . $order_id); $pdf->SetSubject($order['realname']); $pdf->SetKeywords('指尖分期,' . $order['realname'] . ',' . $order_id); $pdf->setFooterData(array(0, 0, 0), array(122, 122, 122)); $pdf->setPrintHeader(false); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(8); $pdf->SetY(-10); $pdf->SetFont('stsongstdlight', 'N', 9); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, 9); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('stsongstdlight', '', 11); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); $cur_month = strtotime(date('Y-m-01', $order['created'])); $next_month = strtotime('+1 month', $cur_month); $first_repay_day = date('Y-m-', $next_month) . date('d', $order['created']); $first_repay_day = min($first_repay_day, date('Y-m-t', $next_month)); if (in_array($order['type'], [2, 3, 4])) { // 线下/现金/全网分期 $html = '<p style="text-align:right;font-weight:bold;">协议编号:<span style="border-bottom:1px solid #000;">' . $order_id . '</span></p> <h1 style="text-align:center">商品分期服务协议</h1> <p>甲方:广西云尚文化产业投资有限公司<br>客服电话:400-611-8602</p> <p>乙方:<span style="border-bottom:1px solid #000;">' . $order['realname'] . '</span><br>身份证:<span style="border-bottom:1px solid #000;">' . $contract['id_card'] . '</span><br>手机号:<span style="border-bottom:1px solid #000;">' . $order['mobile'] . '</span></p> <p>根据《中华人民共和国合同法》等法律法规,双方本着平等自愿,公平公正,协商一致等原则,达成如下协议:</p> <h2>第一条 分期服务</h2> <table border="1"> <tr><td>商品/服务名称</td><td>' . $order['title'] . '</td><td>乙方分期金额</td><td>' . $order['loan_money'] . '元</td></tr> <tr><td>分期月数</td><td>' . $order['month'] . '个月</td><td>每月还款金额[本金+服务费]</td><td>' . $order['month_total'] . '元</td></tr> <tr><td>每月还款日</td><td>每月' . date('j', $order['created']) . '日</td><td>首期还款日</td><td>' . $first_repay_day . '</td></tr> <tr><td colspan="4">此订单为代购,指尖分期商城只提供分期服务,不对商品/服务质量负责。</td></tr> </table> <h2>第二条 甲方权利和义务</h2> <ol><li>甲方应按照本合同约定为乙方提供指尖分期网站的相关服务。 </li><li>妥善保管乙方在甲方所运营的指尖分期网站上注册登记的个人信息。 </li><li>甲方不承担乙方使用标的物过程中乙方或第三方人身伤亡或者财产损失所引发的责任。 </li></ol> <h2>第三条 乙方权利和义务</h2> <ol> <li>乙方应将本合同第一条所约定的每月还款金额在每月还款日前足额支付给甲方。</li> <li>乙方应提供有效期内的本人证件以及其他甲方要求的信息,由甲方工作人员核对。</li> </ol> <h2>第四条 违约责任</h2> <ol><li>乙方若未能依本合同的约定按时支付总价款,则须向甲方支付滞纳金,滞纳金的金额按所有未偿还价款总金额的【1%】为日息进行征收(不到1日按1日计算)。 </li><li>如乙方累计拖欠甲方费用达【10】日或以上则甲方可通过书面、短信、电子邮件、电话等任一形式通知乙方解除本合同,乙方全部未偿还价款必须在自本合同解除日起【3】日内一次付清。同时,乙方必须在自本合同解除【3】日内,另向甲方支付合同未偿还价款总金额的【30%】作为违约金。如乙方延迟支付未偿还价款和违约金,每延迟【1】日,甲方有权加收应付款项(未偿还价款加违约金之和)的【1%】作为滞纳金,甲方已收取的款项(包括但不限于:首付、首期分期款、滞纳金等)不再退回。 </li><li>如乙方于还款期内有逾期还款的行为,甲方将有权免去给予乙方的任何优惠措施(包括但不限于0服务费等),在追款中产生的费用(包括但不限于调查费、诉讼费、律师费、往返路费、餐费、住宿费、电话费等)全部由乙方承担。 </li><li>乙方应保证其向甲方提供的信息真实有效、合法合规且全面,不存在任何虚假、遗漏或重大错误。如甲方发现乙方提供虚假或错误信息,将视为合同欺诈,乙方必须在自甲方发现之日起【3】日内付清全部未偿还价款,并另向甲方支付本合同总价款的【10%】作为赔偿金,已经收取的款项不予退回。如乙方延迟支付未偿还价款和赔偿金,每延迟【1】日,甲方有权向乙方加收应付款项(未偿还价款加赔偿金之和)的【1%】作为滞纳金。 </li><li>乙方如有违约行为,且出现逃避支付、拒绝沟通或者恶意拖欠还款等情形的甲方有权将乙方的个人信息及其信用信息向征信机构披露,并有权在其网站上公布相关信息,在本条所述违约情形下,甲方亦有权将乙方违约的相关信息及乙方信息向所在学校及管理机构如实披露,由此引发的后果,甲方不承担任何法律责任。 </li><li>若在规定期限内乙方无法偿还所欠款项,甲方向乙方提供有偿的兼职劳务岗位帮助乙方实现劳务代偿欠款,如乙方拒绝劳务代偿又无法支付欠款,甲方有权要求乙方一次性还清欠款与及约定的违约金、滞纳金。 </li><li>如果乙方违约,乙方同意甲方或其聘请的第三方催收机构以直接上门、邮件、电话或其他方式向乙方进行追款,乙方不得提出任何异议,由此产生的一切费用由乙方承担。 </li></ol> <h2>第五条 授权委托</h2> <ol><li>现乙方委托甲方在第三方平台或机构上向第三方平台或机构出借人(以下简称“出借人”)融资,融资金额即为签订合同时乙方尚未支付的金额(“应付款项”)。融资款项仅限于支付该应付款项,甲方指定乙方作为融资款项的收款人。同时甲方在此过程中为乙方提供咨询、办理融资申请、还款管理等服务。经甲方推荐且前述融资匹配成功后,甲方、乙方、第三方平台、出借人等将以电子文本形式签订《分期服务协议》。 </li><li>乙方同意,甲方作为受托融资人处理如下:<br /> (1)自主决定实现融资的理财平台,并确定有意向的资金提供方(“投资人”);<br /> (2)应理财平台或投资人的要求,在合理范围内向投资人和理财平台披露乙方资信材料,包括但不限于年龄,性别,锁在学校,专业等,并视情况引入增信措施。<br /> (3)代收乙方应向投资人及理财平台的融资款及融资成本费。<br /> (4)代收本条第(3)项的相关费用。<br /> (5)代收乙方从投资人出融到的款项,并向标的物销售方代付款项。<br /> (6)指定接收涉及本条第(3)项及第(5)项的账户。<br /> (7)以乙方名义签署和理财平台、投资人以及甲方作为保证人的《商品分期服务协议》;<br /> (8)代理在第三方平台融资所需的手续。 </li><li>乙方授权甲方及/或第三方平台在约定还款日期代扣应支付给出借人的本金、利息以及支付给第三方平台的费用,并按《商品分期服务协议》约定的还款日代付给相关个人及公司。 </li><li>授权甲方及/或第三方平台及/或相关金融机构在相关机构平台(包括但不限于:金融机构、工商、税务、征信机构、人民法院等)查询、确认乙方相关的征信信息。 </li><li>乙方同意并授权甲方在审核其信用记录、后续风险管理、提供综合化服务的过程中,向依法设立的征信机构及气体相关合法机构了解和查询其资产、资讯、个人信用信息等情况,并保留相关资料。 </li><li>乙方同意采用电子文本形式制作《商品分期服务协议》,且乙方确认已仔细阅读及不可撤销的同意该电子协议的全部条款,一经甲方及/或第三方平台通过该第三方平台账户在第三方平台对《商品分期服务协议》进行确认,相关协议即对乙方形成效力,乙方同意受《商品分期服务协议》相关内容的约束。 </li><li>授权甲方代为接收第三方平台向乙方发送的相关信息(包括但不限于分期服务协议电子文本,债权转让协议通知等),该等信息在发送至甲方时即视为送达乙方。 </li><li>乙方授权甲方可将上述委托事项部分或全部转委托。 </li><li>委托期限:自合同生效之日起至甲方或第三方平台代乙方在第三方平台签署电子文本形式的《商品分期服务协议》项下确认乙方的义务全部履行完毕之日止。 </li><li>特别委托:乙方在此不可撤销的承诺,乙方在《商品分期服务协议》项下乙方未全部履行完毕之前,不得单方面解除或终止上述对甲方及/或第三方平台的委托。 </li><li>若乙方未按照相关融资协议履行偿还义务,甲方进行预期垫付融资款项以及融资利息和理财平台费用,自甲方代偿之日起,乙方应当在【3】个工作日内向甲方偿还上诉款项,并向甲方支付违约金:代偿款项*【1】%*逾期天数,为避免疑义,逾期天数自乙方预期偿还代偿融资款项及融资利息或服务费之日起计算,至乙方向甲方偿还该等代偿融资款项及融资利息或服务费以及违约金之日截止。 </li></ol> <h2>第六条 争议解决</h2> <p>本协议在履行过程中如发生争议,双方应协商解决;协商不成,可向仲裁机构提交仲裁申请进行调解,不愿调解的甲乙双方均可向甲乙方所在地的法院起诉。</p> <h2>第七条 合同的变更和解除</h2> <p>除合同另有约定外,任何一方均不得单方面变更或解除本合同,对本合同或其他条款内容有任何补充、修改或变更,必须经过双方事先达成书面协议方可作实。 </p> <h2>第八条 合同的生效</h2> <ol> <li>本协议以电子文本形式生成。 </li><li>本协议的任何修改、补充均须以甲方平台电子文本形式做出。 </li><li>乙方委托甲方保管所有与本协议有关的书面文件或电子信息。 </li><li>双方确认,本协议由乙方通过甲方运营的网站、手机客户端以网络在线点击确认的方式进行签署。 </li><li>乙方下单分期时阅读本协议电子版并点击确认,甲方派工作人员当面与乙方确认订单信息与协议内容,乙方确认所有事项后签署订单确认书并由乙方本人手持订单确认书拍照作为不可抵赖的法律证据由甲方保存。 </li><li>甲方审核完订单信息后完成订单付款操作后本协议自动生效,协议双方不得有异议。 </li> </ol> <h2>第九条 银行代扣</h2> <p>为方便甲、乙双方关于商品分期付款费用的收缴工作,经双方协商,除支付宝支付外也可选用指定银行卡支付,银行卡指定开户行在广西区内为桂林银行,乙方在桂林银行开设预定代扣银行卡,每个月在还款期限达到前将资金划拨到该银行卡,用于支付乙方每月的分期付款费用。 </p> <br /> <p style="font-weight:bold;">乙方承诺:本人保证所提供的个人资料信息真实,有效。并依据详细了解所填合同章程,业务协议,功能说明及责任条款,同意接受相关业务章程和协议的约束,以上条款本人已经确认并知晓。</p> <br />'; $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // $pdf->AddPage (); $img = $order_auth[9] ? '<img src="' . $order_auth[9] . '?imageMogr2/auto-orient/thumbnail/2000x2000" border="0" />' : ''; $pdf->writeHTMLCell(0, 0, '', '', '<h2>第十条 附件资料</h2><div style="border:1px solid #000;padding:10px;margin-bottom:10px;"><p style="text-align:center;">(手持确认书)</p>' . $img . '</div>', 0, 1, 0, true, '', true); } else { // 线上代购 $html = '<p style="text-align:right;font-weight:bold;">协议编号:<span style="border-bottom:1px solid #000;">' . $order_id . '</span></p> <h1 style="text-align:center">商品分期服务协议</h1> <p>甲方:广西云尚文化产业投资有限公司<br>客服电话:400-611-8602</p> <p>乙方:<span style="border-bottom:1px solid #000;">' . $order['realname'] . '</span><br>身份证:<span style="border-bottom:1px solid #000;">' . $contract['id_card'] . '</span><br>手机号:<span style="border-bottom:1px solid #000;">' . $order['mobile'] . '</span></p> <p>根据《中华人民共和国合同法》等法律法规,双方本着平等自愿,公平公正,协商一致等原则,达成如下协议:</p> <h2>第一条 分期服务</h2> <table border="1"> <tr><td>商品/服务名称</td><td>' . $order['title'] . '</td><td>乙方分期金额</td><td>' . $order['loan_money'] . '元</td></tr> <tr><td>分期月数</td><td>' . $order['month'] . '个月</td><td>每月还款金额[本金+服务费]</td><td>' . $order['month_total'] . '元</td></tr> <tr><td>每月还款日</td><td>每月' . date('j', $order['created']) . '日</td><td>首期还款日</td><td>' . $first_repay_day . '</td></tr> </table> <h2>第二条 甲方权利和义务</h2> <ol><li>甲方应按照本合同约定为乙方提供指尖分期网站的相关服务。 </li><li>妥善保管乙方在甲方所运营的指尖分期网站上注册登记的个人信息。 </li><li>甲方不承担乙方使用标的物过程中乙方或第三方人身伤亡或者财产损失所引发的责任。 </li></ol> <h2>第三条 乙方权利和义务</h2> <ol> <li>乙方应将本合同第一条所约定的每月还款金额在每月还款日前足额支付给甲方。</li> <li>乙方应提供有效期内的本人证件以及其他甲方要求的信息,由甲方工作人员核对。</li> </ol> <h2>第四条 违约责任</h2> <ol><li>乙方若未能依本合同的约定按时支付总价款,则须向甲方支付滞纳金,滞纳金的金额按所有未偿还价款总金额的【1%】为日息进行征收(不到1日按1日计算)。 </li><li>如乙方累计拖欠甲方费用达【10】日或以上则甲方可通过书面、短信、电子邮件、电话等任一形式通知乙方解除本合同,乙方全部未偿还价款必须在自本合同解除日起【3】日内一次付清。同时,乙方必须在自本合同解除【3】日内,另向甲方支付合同未偿还价款总金额的【30%】作为违约金。如乙方延迟支付未偿还价款和违约金,每延迟【1】日,甲方有权加收应付款项(未偿还价款加违约金之和)的【1%】作为滞纳金,甲方已收取的款项(包括但不限于:首付、首期分期款、滞纳金等)不再退回。 </li><li>如乙方于还款期内有逾期还款的行为,甲方将有权免去给予乙方的任何优惠措施(包括但不限于0服务费等),在追款中产生的费用(包括但不限于调查费、诉讼费、律师费、往返路费、餐费、住宿费、电话费等)全部由乙方承担。 </li><li>乙方应保证其向甲方提供的信息真实有效、合法合规且全面,不存在任何虚假、遗漏或重大错误。如甲方发现乙方提供虚假或错误信息,将视为合同欺诈,乙方必须在自甲方发现之日起【3】日内付清全部未偿还价款,并另向甲方支付本合同总价款的【10%】作为赔偿金,已经收取的款项不予退回。如乙方延迟支付未偿还价款和赔偿金,每延迟【1】日,甲方有权向乙方加收应付款项(未偿还价款加赔偿金之和)的【1%】作为滞纳金。 </li><li>乙方如有违约行为,且出现逃避支付、拒绝沟通或者恶意拖欠还款等情形的甲方有权将乙方的个人信息及其信用信息向征信机构披露,并有权在其网站上公布相关信息,在本条所述违约情形下,甲方亦有权将乙方违约的相关信息及乙方信息向所在学校及管理机构如实披露,由此引发的后果,甲方不承担任何法律责任。 </li><li>若在规定期限内乙方无法偿还所欠款项,甲方向乙方提供有偿的兼职劳务岗位帮助乙方实现劳务代偿欠款,如乙方拒绝劳务代偿又无法支付欠款,甲方有权要求乙方一次性还清欠款与及约定的违约金、滞纳金。 </li><li>如果乙方违约,乙方同意甲方或其聘请的第三方催收机构以直接上门、邮件、电话或其他方式向乙方进行追款,乙方不得提出任何异议,由此产生的一切费用由乙方承担。 </li></ol> <h2>第五条 授权委托</h2> <ol><li>现乙方委托甲方在第三方平台或机构上向第三方平台或机构出借人(以下简称“出借人”)融资,融资金额即为签订合同时乙方尚未支付的金额(“应付款项”)。融资款项仅限于支付该应付款项,甲方指定乙方作为融资款项的收款人。同时甲方在此过程中为乙方提供咨询、办理融资申请、还款管理等服务。经甲方推荐且前述融资匹配成功后,甲方、乙方、第三方平台、出借人等将以电子文本形式签订《分期服务协议》。 </li><li>乙方同意,甲方作为受托融资人处理如下:<br /> (1)自主决定实现融资的理财平台,并确定有意向的资金提供方(“投资人”);<br /> (2)应理财平台或投资人的要求,在合理范围内向投资人和理财平台披露乙方资信材料,包括但不限于年龄,性别,锁在学校,专业等,并视情况引入增信措施。<br /> (3)代收乙方应向投资人及理财平台的融资款及融资成本费。<br /> (4)代收本条第(3)项的相关费用。<br /> (5)代收乙方从投资人出融到的款项,并向标的物销售方代付款项。<br /> (6)指定接收涉及本条第(3)项及第(5)项的账户。<br /> (7)以乙方名义签署和理财平台、投资人以及甲方作为保证人的《商品分期服务协议》;<br /> (8)代理在第三方平台融资所需的手续。 </li><li>乙方授权甲方及/或第三方平台在约定还款日期代扣应支付给出借人的本金、利息以及支付给第三方平台的费用,并按《商品分期服务协议》约定的还款日代付给相关个人及公司。 </li><li>授权甲方及/或第三方平台及/或相关金融机构在相关机构平台(包括但不限于:金融机构、工商、税务、征信机构、人民法院等)查询、确认乙方相关的征信信息。 </li><li>乙方同意并授权甲方在审核其信用记录、后续风险管理、提供综合化服务的过程中,向依法设立的征信机构及气体相关合法机构了解和查询其资产、资讯、个人信用信息等情况,并保留相关资料。 </li><li>乙方同意采用电子文本形式制作《商品分期服务协议》,且乙方确认已仔细阅读及不可撤销的同意该电子协议的全部条款,一经甲方及/或第三方平台通过该第三方平台账户在第三方平台对《商品分期服务协议》进行确认,相关协议即对乙方形成效力,乙方同意受《商品分期服务协议》相关内容的约束。 </li><li>授权甲方代为接收第三方平台向乙方发送的相关信息(包括但不限于分期服务协议电子文本,债权转让协议通知等),该等信息在发送至甲方时即视为送达乙方。 </li><li>乙方授权甲方可将上述委托事项部分或全部转委托。 </li><li>委托期限:自合同生效之日起至甲方或第三方平台代乙方在第三方平台签署电子文本形式的《商品分期服务协议》项下确认乙方的义务全部履行完毕之日止。 </li><li>特别委托:乙方在此不可撤销的承诺,乙方在《商品分期服务协议》项下乙方未全部履行完毕之前,不得单方面解除或终止上述对甲方及/或第三方平台的委托。 </li><li>若乙方未按照相关融资协议履行偿还义务,甲方进行预期垫付融资款项以及融资利息和理财平台费用,自甲方代偿之日起,乙方应当在【3】个工作日内向甲方偿还上诉款项,并向甲方支付违约金:代偿款项*【1】%*逾期天数,为避免疑义,逾期天数自乙方预期偿还代偿融资款项及融资利息或服务费之日起计算,至乙方向甲方偿还该等代偿融资款项及融资利息或服务费以及违约金之日截止。 </li></ol> <h2>第六条 争议解决</h2> <p>本协议在履行过程中如发生争议,双方应协商解决;协商不成,可向仲裁机构提交仲裁申请进行调解,不愿调解的甲乙双方均可向甲乙方所在地的法院起诉。</p> <h2>第七条 合同的变更和解除</h2> <p>除合同另有约定外,任何一方均不得单方面变更或解除本合同,对本合同或其他条款内容有任何补充、修改或变更,必须经过双方事先达成书面协议方可作实。 </p> <h2>第八条 合同的生效</h2> <ol> <li>本协议以电子文本形式生成。 </li><li>本协议的任何修改、补充均须以甲方平台电子文本形式做出。 </li><li>乙方委托甲方保管所有与本协议有关的书面文件或电子信息。 </li><li>双方确认,本协议由乙方通过甲方运营的网站、手机客户端以网络在线点击确认的方式进行签署。 </li><li>乙方下单分期时阅读本协议电子版并点击确认,甲方派工作人员当面与乙方确认订单信息与协议内容,乙方确认所有事项后签署订单确认书并由乙方本人手持订单确认书拍照作为不可抵赖的法律证据由甲方保存。 </li><li>甲方审核完订单信息后完成订单付款操作后本协议自动生效,协议双方不得有异议。 </li> </ol> <h2>第九条 银行代扣</h2> <p>为方便甲、乙双方关于商品分期付款费用的收缴工作,经双方协商,除支付宝支付外也可选用指定银行卡支付,银行卡指定开户行在广西区内为桂林银行,乙方在桂林银行开设预定代扣银行卡,每个月在还款期限达到前将资金划拨到该银行卡,用于支付乙方每月的分期付款费用。 </p> <h2>第十条 退换货政策以第三方销售商退换货政策为准。</h2> <ol> <li>因下述原因造成乙方未能预期收到标的物或标的物不符合乙方的预期的,由乙方自行承担相关风险,且不影响乙方在本合同项下履行向甲方支付代理服务费的义务: (1)乙方提供的购物信息不实或者有误;<br /> (2)乙方未及时签收标的物;<br /> (3)标的物本身的质量、物流、售后等可归咎于销售方、物流公司或者其他第三方的问题等。乙方因本条上述原因退货产生的费用(包含但不限于:对应账单生成到取消期间甲方的服务费、运费、第三方销售商的手续费等)均由乙方承担。乙方退换货成功,相关款项退到甲方账户后,此费用根据甲方网站公布的规定生成新账单,乙方不得因退换货成功而拒绝承担此费用。 </li><li>乙方在签署本合同后应及时接收标的物。如乙方因故不能接收标的物的,应与第三方销售商或相关物流协商延期。如协商不成或乙方延期提取标的物超过【3】日的,应视为放弃,乙方不得要求甲方退还任何款项,并需在甲方处置标的物后的【3】日内向甲方支付本合同总价款的1%作为服务费及因此产生的费用。 </li><li>在标的物交付后【7】日内,乙方应对标的物进行全面检查,如存在非乙方原因引起的产品瑕疵或质量问题,乙方可自行联系第三方销售商处理,甲方在此过程中可给予配合。 </li><li>对于标的物在交付后使用过程中产生的产品瑕疵或质量问题,乙方可按照标的物相关的三包条款处理,如质保期限已过或者乙方要求处理的商品与第三方销售商所售商品的序列号不符(以第三方销售商后台记录为准),乙方应自行承担相关责任。 </li><li>标的物的交付时间,以第三方销售商及相关物流商的签收日期为准。标的物交付后,标的物毁损灭失的风险由乙方承担。如乙方将标的物转交第三方,由此产生的风险一概与甲方无关。以上风险承担的规定不影响各自对违约责任及其他责任的主张。 </li> </ol> <br /> <p style="font-weight:bold;margin:0 20px;">乙方承诺:本人保证所提供的个人资料信息真实,有效。并依据详细了解所填合同章程,业务协议,功能说明及责任条款,同意接受相关业务章程和协议的约束,以上条款本人已经确认并知晓。</p> <br />'; $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // $pdf->AddPage (); $img = $order_auth[9] ? '<img src="' . $order_auth[9] . '?imageMogr2/auto-orient/thumbnail/2000x2000" border="0" />' : ''; $pdf->writeHTMLCell(0, 0, '', '', '<h2>第十一条 附件资料</h2><div style="border:1px solid #000;padding:10px;margin-bottom:10px;"><p style="text-align:center;">(手持确认书)</p>' . $img . '</div>', 0, 1, 0, true, '', true); } // --------------------------------------------------------- $base_dir = THINK_PATH . '../../static.zjfq'; $save_dir = '/order/contract/' . date('Ymd') . '/'; $filename = md5('order' . $order_id . 'contract') . '.pdf'; $save_dir_all = $base_dir . $save_dir; is_dir($save_dir_all) or mkdir($save_dir_all, 0777, true); if ($save_to_file) { $pdf->Output($save_dir_all . $filename, 'F'); unset($pdf); return $save_dir . $filename; } else { $pdf->Output($save_dir_all . $filename, 'I'); unset($pdf); return; } unset($pdf); }
/** * generate_pdf. */ public function generate_pdf($get_by_order_id = 0) { if (!isset($_GET['pdf_invoice']) && 0 == $get_by_order_id) { return; } $order_id = 0 == $get_by_order_id ? $_GET['pdf_invoice'] : $get_by_order_id; if (!is_user_logged_in() && 0 == $get_by_order_id) { return; } if (!current_user_can('administrator') && !is_shop_manager() && get_current_user_id() != intval(get_post_meta($order_id, '_customer_user', true)) && 0 == $get_by_order_id) { return; } // Include the main TCPDF library (search for installation path). //require_once('tcpdf_include.php'); require_once 'lib/tcpdf_min/tcpdf.php'; // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); //$pdf->SetAuthor( 'Algoritmika Ltd.' ); $pdf->SetTitle('Invoice'); $pdf->SetSubject('Invoice PDF'); $pdf->SetKeywords('invoice, PDF'); // set default header data // TODO 2014.09.21 // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128)); //$pdf->SetHeaderData( get_option( 'wcj_pdf_invoices_seller_logo_url' ), 30, get_option( 'wcj_pdf_invoices_header_title' ), get_option( 'wcj_pdf_invoices_header_string' ), array(0,64,255), array(0,64,128)); $pdf->SetPrintHeader(false); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); //$pdf->SetPrintFooter(false); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); /* // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } */ // --------------------------------------------------------- // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont(apply_filters('wcj_get_option_filter', 'dejavusans', get_option('wcj_pdf_invoices_general_font_family', 'dejavusans')), '', apply_filters('wcj_get_option_filter', 8, get_option('wcj_pdf_invoices_general_font_size')), '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); if ('yes' === get_option('wcj_pdf_invoices_general_font_shadowed', 'yes')) { // set text shadow effect $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); } $html = $this->get_invoice_html($order_id); // Print text using writeHTMLCell() $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. // $the_order = new WC_Order( $order_id ); // $order_number = $the_order->get_order_number(); /**/ if ($get_by_order_id > 0) { return $pdf->Output('invoice-' . $order_id . '.pdf', 'S'); } else { $file_name = 'invoice-' . $order_id . '.pdf'; $file_path = sys_get_temp_dir() . '/' . $file_name; $result = file_put_contents($file_path, $pdf->Output('', 'S')); //echo $pdf->Output( '', 'S' ); if (isset($_GET['save_pdf_invoice']) && '1' == $_GET['save_pdf_invoice']) { //$pdf->Output('invoice-' . $order_id . '.pdf', 'D'); header("Content-Type: application/octet-stream"); //$file = $file_name;//$_GET["file"] .".pdf"; header("Content-Disposition: attachment; filename=" . urlencode($file_name)); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); } else { //$pdf->Output('invoice-' . $order_id . '.pdf', 'I'); header("Content-type: application/pdf"); header("Content-Disposition: inline; filename=" . urlencode($file_name)); } header("Content-Length: " . filesize($file_path)); flush(); // this doesn't really matter. if (false !== ($fp = fopen($file_path, "r"))) { while (!feof($fp)) { echo fread($fp, 65536); flush(); // this is essential for large downloads } fclose($fp); } else { die(__('Unexpected error', 'woocommerce-jetpack')); } } /**/ /** if ( $get_by_order_id > 0 ) return $pdf->Output('invoice-' . $order_id . '.pdf', 'S'); if ( isset( $_GET['save_pdf_invoice'] ) && '1' == $_GET['save_pdf_invoice'] ) $pdf->Output('invoice-' . $order_id . '.pdf', 'D'); else $pdf->Output('invoice-' . $order_id . '.pdf', 'I'); /**/ }