function display($tpl = null) { $mainframe =& JFactory::getApplication(); $dispatcher =& JDispatcher::getInstance(); /* Load the event details */ $course = $this->get('Details'); $venue = $this->get('Venue'); $pdf = new TCPDF("P", "mm", "A4", true); $pdf->SetCreator($mainframe->getCfg('sitename')); $pdf->SetAuthor($mainframe->getCfg('sitename')); $pdf->SetTitle($course->title); $pdf->SetSubject($course->title); $pdf->setHeaderFont(array('freesans', '', 8)); $pdf->setFooterFont(array('freesans', '', 8)); $pdf->setFont('freesans'); // disable header and footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(true); //set the display mode $pdf->SetDisplayMode('default'); //initialize document $pdf->AliasNbPages(); // add a page $pdf->AddPage(); $pdf->SetFontSize(10); /* This loads the tags replacer */ JView::loadHelper('tags'); $tags = new redEVENT_tags(); $tags->setXref(JRequest::getInt('xref')); $message = $tags->ReplaceTags($course->submission_type_email_pdf); // convert urls $htmlmsg = REOutput::ImgRelAbs($message); $pdf->WriteHTML($message, true); // add the form data if requested if ($course->pdf_form_data) { JRequest::setVar('pdfform', $pdf); JPluginHelper::importPlugin('content'); $form = new stdClass(); $form->text = '{redform}' . $course->redform_id . ',1{/redform}'; $form->eventid = $course->did; $form->task = 'userregister'; $results = $dispatcher->trigger('onPrepareEvent', array(&$form, array(), 0)); $pdf->WriteHTML($form->text, true); } // output the file $pdf->Output($course->title . ".pdf", "I"); exit; }
/** * Adds to the TCPDF instance, the data related to a row in the GIS dataset. * * @param string $spatial GIS MULTIPOINT object * @param string $label Label for the GIS MULTIPOINT object * @param string $point_color Color for the GIS MULTIPOINT object * @param array $scale_data Array containing data related to scaling * @param TCPDF $pdf TCPDF instance * * @return TCPDF the modified TCPDF instance * @access public */ public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf) { /** @var PMA_String $pmaString */ $pmaString = $GLOBALS['PMA_String']; // allocate colors $red = hexdec($pmaString->substr($point_color, 1, 2)); $green = hexdec($pmaString->substr($point_color, 3, 2)); $blue = hexdec($pmaString->substr($point_color, 4, 2)); $line = array('width' => 1.25, 'color' => array($red, $green, $blue)); // Trim to remove leading 'MULTIPOINT(' and trailing ')' $multipoint = $pmaString->substr($spatial, 11, $pmaString->strlen($spatial) - 12); $points_arr = $this->extractPoints($multipoint, $scale_data); foreach ($points_arr as $point) { // draw a small circle to mark the point if ($point[0] != '' && $point[1] != '') { $pdf->Circle($point[0], $point[1], 2, 0, 360, 'D', $line); } } // print label for each point if (isset($label) && trim($label) != '' && ($points_arr[0][0] != '' && $points_arr[0][1] != '')) { $pdf->SetXY($points_arr[0][0], $points_arr[0][1]); $pdf->SetFontSize(5); $pdf->Cell(0, 0, trim($label)); } return $pdf; }
/** * Adds to the TCPDF instance, the data related to a row in the GIS dataset. * * @param string $spatial GIS POLYGON object * @param string $label Label for the GIS POLYGON object * @param string $fill_color Color for the GIS POLYGON object * @param array $scale_data Array containing data related to scaling * @param TCPDF $pdf TCPDF instance * * @return TCPDF the modified TCPDF instance * @access public */ public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf) { // allocate colors $red = hexdec(mb_substr($fill_color, 1, 2)); $green = hexdec(mb_substr($fill_color, 3, 2)); $blue = hexdec(mb_substr($fill_color, 4, 2)); $color = array($red, $green, $blue); // Trim to remove leading 'POLYGON((' and trailing '))' $polygon = mb_substr($spatial, 9, mb_strlen($spatial) - 11); // If the polygon doesn't have an inner polygon if (mb_strpos($polygon, "),(") === false) { $points_arr = $this->extractPoints($polygon, $scale_data, true); } else { // Separate outer and inner polygons $parts = explode("),(", $polygon); $outer = $parts[0]; $inner = array_slice($parts, 1); $points_arr = $this->extractPoints($outer, $scale_data, true); foreach ($inner as $inner_poly) { $points_arr = array_merge($points_arr, $this->extractPoints($inner_poly, $scale_data, true)); } } // draw polygon $pdf->Polygon($points_arr, 'F*', array(), $color, true); // print label if applicable if (isset($label) && trim($label) != '') { $pdf->SetXY($points_arr[2], $points_arr[3]); $pdf->SetFontSize(5); $pdf->Cell(0, 0, trim($label)); } return $pdf; }
/** * Adds to the TCPDF instance, the data related to a row in the GIS dataset. * * @param string $spatial GIS MULTILINESTRING object * @param string $label Label for the GIS MULTILINESTRING object * @param string $line_color Color for the GIS MULTILINESTRING object * @param array $scale_data Array containing data related to scaling * @param TCPDF $pdf TCPDF instance * * @return TCPDF the modified TCPDF instance * @access public */ public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { /** @var PMA_String $pmaString */ $pmaString = $GLOBALS['PMA_String']; // allocate colors $red = hexdec($pmaString->substr($line_color, 1, 2)); $green = hexdec($pmaString->substr($line_color, 3, 2)); $blue = hexdec($pmaString->substr($line_color, 4, 2)); $line = array('width' => 1.5, 'color' => array($red, $green, $blue)); // Trim to remove leading 'MULTILINESTRING((' and trailing '))' $multilinestirng = $pmaString->substr($spatial, 17, $pmaString->strlen($spatial) - 19); // Separate each linestring $linestirngs = explode("),(", $multilinestirng); $first_line = true; foreach ($linestirngs as $linestring) { $points_arr = $this->extractPoints($linestring, $scale_data); foreach ($points_arr as $point) { if (!isset($temp_point)) { $temp_point = $point; } else { // draw line section $pdf->Line($temp_point[0], $temp_point[1], $point[0], $point[1], $line); $temp_point = $point; } } unset($temp_point); // print label if (isset($label) && trim($label) != '' && $first_line) { $pdf->SetXY($points_arr[1][0], $points_arr[1][1]); $pdf->SetFontSize(5); $pdf->Cell(0, 0, trim($label)); } $first_line = false; } return $pdf; }
function nv_giapha_export_pdf($contents, $background, $row_genealogy) { global $db, $db_config, $lang_module, $lang_global, $module_name, $module_data; require_once NV_ROOTDIR . '/includes/class/phpPdf/config/lang/eng.php'; require_once NV_ROOTDIR . '/includes/class/phpPdf/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('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 001'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); $pdf->SetFont('dejavusans', '', 14, '', true); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $row_genealogy['title'], $row_genealogy['full_name'] . ' - ' . $row_genealogy['email']); // set header and footer fonts $pdf->setHeaderFont(array('dejavusans', '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array('dejavusans', '', 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. // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); if (!empty($contents['biagp'])) { if (!empty($background) && file_exists($background)) { // -- set new background --- // get the current page break margin $bMargin = $pdf->getBreakMargin(); // get current auto-page-break mode $auto_page_break = $pdf->getAutoPageBreak(); // disable auto-page-break $pdf->SetAutoPageBreak(false, 0); // set bacground image $pdf->Image($background, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0); // restore auto-page-break status $pdf->SetAutoPageBreak($auto_page_break, $bMargin); // set the starting point for the page content $pdf->setPageMark(); } //============================================================+ // END OF FILE //============================================================+ // Persian and English content $pdf->WriteHTML($contents['biagp'], true, 0, true, 0); } if ($contents['phaky']) { // output the HTML content $pdf->WriteHTML("<h2><i style=\"color:#990000;text-decoration: underline;\">Phả ký</i></h2>", true, 0, true, 0); $pdf->Ln(2); $pdf->WriteHTML("<span style=\"font-size:35px;\">" . $contents['phaky'] . "</span>", true, 0, true, 0); } if ($contents['phado']) { // output the HTML content $pdf->WriteHTML("<h2><i style=\"color:#990000;text-decoration: underline;\">Phả đồ</i></h2>", true, 0, true, 0); $pdf->Ln(2); foreach ($contents['phado'] as $phado) { $pdf->writeHTML($phado, true, false, true, false, ''); } } if ($contents['tocuoc']) { // output the HTML content $pdf->WriteHTML("<h2><i style=\"color:#990000;text-decoration: underline;\">Tộc ước</i></h2>", true, 0, true, 0); $pdf->Ln(2); $pdf->WriteHTML($contents['tocuoc'], true, 0, true, 0); } if ($contents['huonghoa']) { // output the HTML content $pdf->WriteHTML("<h2><i style=\"color:#990000;text-decoration: underline;\">Hương hỏa</i></h2>", true, 0, true, 0); $pdf->Ln(2); $pdf->WriteHTML($contents['huonghoa'], true, 0, true, 0); } if ($contents['ngaygio']) { // output the HTML content $pdf->WriteHTML("<h2><i style=\"color:#990000;text-decoration: underline;\">Ngày giỗ</i></h2>", true, 0, true, 0); $pdf->Ln(2); $pdf->SetFillColor(221, 238, 255); if (empty($array_data) && empty($array_anniversary)) { $pdf->Cell(0, 10, 'Không có dữ liệu', 1, 1, 'C', true, '', 0, false, 'T', 'M'); } else { $array_data = $contents['ngaygio']['genealogy']; $array_anniversary = $contents['ngaygio']['anniversary']; // print font name $pdf->Cell(0, 10, 'Ngày giỗ:' . $array_data['title'], 1, 1, 'C', true, '', 0, false, 'T', 'M'); $pdf->SetFillColor(168, 164, 204); $pdf->Cell(20, 12, 'STT', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(110, 12, 'Họ tên', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(50, 12, 'Ngày giỗ', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Ln(); // set font for chars $pdf->SetFont($font, '', 16); $i = 0; foreach ($array_anniversary as $row) { $i++; $row['number'] = $i; $pdf->Cell(20, 12, $row['number'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(110, 12, $row['full_name'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(50, 12, $row['date'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Ln(); } } $pdf->Ln(10); } if ($contents['thanhvien']) { //array allow $array_key = array('image', 'full_name', 'gender', 'status', 'code', 'name1', 'name2', 'birthday', 'dieday', 'life', 'burial'); $row_detail = $contents['thanhvien']['detail']; $pdf->SetFillColor(221, 238, 255); // print font name $pdf->Cell(0, 10, 'Trưởng họ', 1, 1, 'C', true, '', 0, false, 'T', 'M'); // set font for chars $pdf->SetFont($font, '', 13); $pdf->SetFontSize(13); foreach ($array_key as $key) { if ($row_detail[$key] != "") { if ($key == "image") { $pdf->Cell(80, 40, $lang_module['u_' . $key], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Image($row_detail[$key], '', '', 40, 40, '', '', 'L', false, 150, '', false, false, 0, false, false, false); $pdf->Cell(100, 40, '', 1, 0, 'R', false, '', 0, false, '', ''); } else { $pdf->Cell(80, 12, $lang_module['u_' . $key], 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(100, 12, $row_detail[$key], 1, 0, 'L', true, '', 1, false, 'T', 'M'); } $pdf->Ln(); } } if (!empty($row_detail['content'])) { $pdf->Ln(10); $pdf->WriteHTML("<h1><i style=\"color:#990000;\">" . $lang_module['u_content'] . "</i></h1>", true, 0, true, 0); $pdf->Ln(2); $pdf->WriteHTML($row_detail['content']); } $array_parentid = $contents['thanhvien']['parentid']; foreach ($array_parentid as $array_parentid_i) { $pdf->Ln(10); $pdf->SetFillColor(221, 238, 255); $pdf->Cell(180, 10, $array_parentid_i['caption'], 1, 1, 'C', true, '', 0, false, 'T', 'M'); $pdf->SetFillColor(168, 164, 204); $pdf->Cell(10, 12, 'STT', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(78, 12, 'Họ tên', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(30, 12, 'Ngày sinh', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(12, 12, 'Ảnh', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, 'Giới tính', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, 'Trạng thái', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Ln(); $items = $array_parentid_i['items']; $number = 1; foreach ($items as $item) { $item['number'] = $number++; $pdf->Cell(10, 12, $item['number'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(78, 12, $item['full_name'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(30, 12, $item['birthday'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Image($item['image'], '', '', 12, 12, '', '', 'L', false, 150, '', false, false, 0, false, false, false); $pdf->Cell(12, 12, '', 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, $item['gender'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, $item['status'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Ln(); } } } if ($contents['chitiet']) { // output the HTML content $pdf->WriteHTML("<h3><i style=\"color:#990000;text-decoration: underline;\">Thông tin chi tiết</i></h3>", true, 0, true, 0); $pdf->Ln(2); $pdf->WriteHTML($contents['chitiet']['them'], true, 0, true, 0); $array_parentid = $contents['chitiet']['array_parentid']; foreach ($array_parentid as $array_parentid_i) { $pdf->Ln(10); $pdf->SetFillColor(221, 238, 255); $pdf->Cell(180, 10, $array_parentid_i['caption'], 1, 1, 'C', true, '', 0, false, 'T', 'M'); $pdf->SetFillColor(168, 164, 204); $pdf->Cell(10, 12, 'STT', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(78, 12, 'Họ tên', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(30, 12, 'Ngày sinh', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(12, 12, 'Ảnh', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, 'Giới tính', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, 'Trạng thái', 1, 0, 'C', true, '', 0, false, 'T', 'M'); $pdf->Ln(); $items = $array_parentid_i['items']; $number = 1; foreach ($items as $item) { $item['number'] = $number++; $pdf->Cell(10, 12, $item['number'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(78, 12, $item['full_name'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(30, 12, $item['birthday'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Image($item['image'], '', '', 12, 12, '', '', 'L', false, 150, '', false, false, 0, false, false, false); $pdf->Cell(12, 12, '', 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, $item['gender'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Cell(25, 12, $item['status'], 1, 0, 'C', false, '', 0, false, 'T', 'M'); $pdf->Ln(); } } } // set LTR direction for english translation $pdf->setRTL(false); $pdf->SetFontSize(10); // print newline $pdf->Ln(); //Close and output PDF document $pdf->Output($row_genealogy['alias'], 'I'); }
$lg['a_meta_dir'] = 'rtl'; $lg['a_meta_language'] = 'fa'; $lg['w_page'] = 'page'; // set some language-dependent strings (optional) $pdf->setLanguageArray($lg); // --------------------------------------------------------- // set font $pdf->SetFont('dejavusans', '', 12); // add a page $pdf->AddPage(); // Persian and English content $htmlpersian = '<span color="#660000">Persian example:</span><br />سلام بالاخره مشکل PDF فارسی به طور کامل حل شد. اینم یک نمونش.<br />مشکل حرف \\"ژ\\" در بعضی کلمات مانند کلمه ویژه نیز بر طرف شد.<br />نگارش حروف لام و الف پشت سر هم نیز تصحیح شد.<br />با تشکر از "Asuni Nicola" و محمد علی گل کار برای پشتیبانی زبان فارسی.'; $pdf->WriteHTML($htmlpersian, true, 0, true, 0); // set LTR direction for english translation $pdf->setRTL(false); $pdf->SetFontSize(10); // print newline $pdf->Ln(); // Persian and English content $htmlpersiantranslation = '<span color="#0000ff">Hi, At last Problem of Persian PDF Solved completely. This is a example for it.<br />Problem of "jeh" letter in some word like "ویژه" (=special) fix too.<br />The joining of laa and alf letter fix now.<br />Special thanks to "Nicola Asuni" and "Mohamad Ali Golkar" for Persian support.</span>'; $pdf->WriteHTML($htmlpersiantranslation, true, 0, true, 0); // Restore RTL direction $pdf->setRTL(true); // set font $pdf->SetFont('aefurat', '', 18); // print newline $pdf->Ln(); // Arabic and English content $pdf->Cell(0, 12, 'بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ', 0, 1, 'C'); $htmlcontent = 'تمَّ بِحمد الله حلّ مشكلة الكتابة باللغة العربية في ملفات الـ<span color="#FF0000">PDF</span> مع دعم الكتابة <span color="#0000FF">من اليمين إلى اليسار</span> و<span color="#009900">الحركَات</span> .<br />تم الحل بواسطة <span color="#993399">صالح المطرفي و Asuni Nicola</span> . '; $pdf->WriteHTML($htmlcontent, true, 0, true, 0);
// --------------------------------------------------------- // set font $pdf->SetFont('times', '', 18); // add a page $pdf->AddPage(); /* * setVisibility() allows to restrict the rendering of some * elements to screen or printout. This can be useful, for * instance, to put a background image or color that will * show on screen but won't print. */ $txt = 'You can limit the visibility of PDF objects to screen or printer by using the setVisibility() method. Check the print preview of this document to display the alternative text.'; $pdf->Write(0, $txt, '', 0, '', true, 0, false, false, 0); // change font size $pdf->SetFontSize(40); // change text color $pdf->SetTextColor(0, 63, 127); // set visibility only for screen $pdf->setVisibility('screen'); // write something only for screen $pdf->Write(0, '[This line is for display]', '', 0, 'C', true, 0, false, false, 0); // set visibility only for print $pdf->setVisibility('print'); // change text color $pdf->SetTextColor(127, 0, 0); // write something only for print $pdf->Write(0, '[This line is for printout]', '', 0, 'C', true, 0, false, false, 0); // restore visibility $pdf->setVisibility('all'); // ---------------------------------------------------------
function writeDetalles(DataSource $dataSource, TCPDF $pdf, $tipo) { $blackAll = array('LTRB' => array('width' => 0.3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); $widthMarginLeft = 1; $width1 = 20; $width2 = 85; $pdf->Ln(); $pdf->SetFontSize(7.5); $pdf->SetFont('', 'B'); $height = 5; $pdf->SetFillColor(255, 255, 255, true); $pdf->setTextColor(0, 0, 0); if ($tipo == 'adjudicado') { $pdf->Cell($width2 - $width1 * 2, $height, 'Item', $blackAll, 0, 'l', true, '', 1, false, 'T', 'C'); } else { $pdf->Cell($width2, $height, 'Item', $blackAll, 0, 'l', true, '', 1, false, 'T', 'C'); } $pdf->Cell($width1, $height, 'Cantidad Ref.', $blackAll, 0, 'L', true, '', 1, false, 'T', 'C'); if ($tipo != 'borrador') { $pdf->Cell($width1, $height, 'Precio Unitario Ref.', $blackAll, 0, 'C', true, '', 1, false, 'T', 'C'); } $pdf->Cell($width1, $height, 'Cantidad Ofert.', $blackAll, 0, 'L', true, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, 'Precio Unitario Ofert.', $blackAll, 0, 'C', true, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, 'Total Ofert.', $blackAll, 0, 'C', true, '', 1, false, 'T', 'C'); if ($tipo == 'adjudicado') { $pdf->Cell($width1, $height, 'Cantidad Adj.', $blackAll, 0, 'l', true, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, 'Total', $blackAll, 0, 'l', true, '', 1, false, 'T', 'C'); } $pdf->Ln(); $pdf->SetFontSize(6.5); foreach ($dataSource->getDataset() as $row) { $pdf->SetFont('', ''); $xAntesMultiCell = $pdf->getX(); $yAntesMultiCell = $pdf->getY(); //$totalItem if ($tipo == 'borrador') { $pdf->MultiCell($width2, $height, $row['desc_solicitud_det'] . "\r\n" . ' - ' . $row['descripcion_sol'], 1, 'L', false, 1); $yDespuesMultiCell = $pdf->getY(); $height = $yDespuesMultiCell - $yAntesMultiCell; $pdf->setXY($xAntesMultiCell + $width2, $yAntesMultiCell); $pdf->Cell($width1, $height, $row['cantidad_sol'], 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, '', 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, '', 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, '', 1, 0, 'R', false, '', 1, false, 'T', 'C'); } else { if ($tipo == 'cotizado') { $pdf->MultiCell($width2, $height, $row['desc_solicitud_det'] . "\r\n" . ' - ' . $row['descripcion_sol'], 1, 'L', false, 1); $yDespuesMultiCell = $pdf->getY(); $height = $yDespuesMultiCell - $yAntesMultiCell; $pdf->setXY($xAntesMultiCell + $width2, $yAntesMultiCell); $pdf->Cell($width1, $height, $row['cantidad_sol'], 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, number_format($row['precio_unitario_sol'], 2), 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, $row['cantidad_coti'], 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, number_format($row['precio_unitario'], 2), 1, 0, 'R', false, '', 1, false, 'T', 'C'); $totalItem = number_format($row['cantidad_coti'] * $row['precio_unitario'], 2); $pdf->Cell($width1, $height, $totalItem, 1, 0, 'R', false, '', 1, false, 'T', 'C'); } else { $pdf->MultiCell($width2 - $width1 * 2, $height, $row['desc_solicitud_det'] . "\r\n" . ' - ' . $row['descripcion_sol'], 1, 'L', false, 1); $yDespuesMultiCell = $pdf->getY(); $height = $yDespuesMultiCell - $yAntesMultiCell; $pdf->setXY($xAntesMultiCell + $width2 - $width1 * 2, $yAntesMultiCell); $pdf->Cell($width1, $height, $row['cantidad_sol'], 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, number_format($row['precio_unitario_sol'], 2), 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, $row['cantidad_coti'], 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, number_format($row['precio_unitario'], 2), 1, 0, 'R', false, '', 1, false, 'T', 'C'); $totalItem = number_format($row['cantidad_coti'] * $row['precio_unitario'], 2); $pdf->Cell($width1, $height, $totalItem, 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, $row['cantidad_adju'], 1, 0, 'R', false, '', 1, false, 'T', 'C'); $totalAdj = number_format($row['cantidad_adju'] * $row['precio_unitario'], 2); $pdf->Cell($width1, $height, $totalAdj, 1, 0, 'R', false, '', 1, false, 'T', 'C'); } } $pdf->Ln(); } }
public function printAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper("layout")->disableLayout(); require_once "../library/zkk/AppCms2/tcpdf/tcpdf.php"; $nOrderId = (int) $this->_getParam("no"); if (is_numeric($nOrderId) && $nOrderId > 0 && in_array($this->_sRoleName, array("librarian", "administrator", "superadministrator"))) { $oModelOrderJournal = new User_Model_VOrderJournal(); $oModelOrderChangeLog = new User_Model_OrderChangeLog(); $oModelOrderJournalOrderChangeLog = new User_Model_OrderJournalOrderChangeLog(); $oOrderJournal = $oModelOrderJournal->getOne($nOrderId); $oPdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, "UTF-8", false); $oPdf->setFont("freesans"); $oPdf->setPrintHeader(false); $oPdf->addPage(); $oPdf->SetFontSize(12); $oPdf->writeHTMLCell(60, 10, "", 5, "<strong>{$oOrderJournal->call_id}</strong>", 0, 0, false, true, "L", true); $oPdf->writeHTMLCell(120, 10, "", "", "ZAKŁADKA ZAMÓWIENIA KOPII", 0, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Numer zamówienia: <strong>{$oOrderJournal->id}</strong>", 0, 0, false, true, "L", true); $oPdf->writeHTMLCell(75, 5, "", "", "Sygnatura: <strong>{$oOrderJournal->call_id}</strong><br />Sygnatura lokalna: <strong>{$oOrderJournal->csa_call_id}</strong><br />Kolekcja: <strong>{$oOrderJournal->collection}</strong>", 0, 1, false, true, "R", true); $oPdf->writeHTMLCell(190, 5, "", "", "", 0, 1, false, true, "L", true); $oPdf->writeHTMLCell(190, 5, "", "", "", 0, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 30, "", "", "Tytuł książki / czasopisma:<br /><strong>{$oOrderJournal->journal_title}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Rocznik: <strong>{$oOrderJournal->journal_year_publication}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Numeracja: <strong>{$oOrderJournal->journal_number}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Strony od: <strong>{$oOrderJournal->page_from}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Strony do: <strong>{$oOrderJournal->page_until}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Autor: <strong>{$oOrderJournal->article_author}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 30, "", "", "Nazwa rozdziału / artykułu:<br /><strong>{$oOrderJournal->article_title}</strong>", 1, 1, false, true, "L", true); $sCurrTime = date("Y-m-d H:i:s", time()); $sHtml1 = "\n Data zamówienia: <strong>{$sCurrTime}</strong><br /><br />\n Zamówione dla: <br /><strong>{$oOrderJournal->user_first_name} {$oOrderJournal->user_last_name}</strong><br /><br />\n Przekazać do: <br /><strong></strong>\n "; $oPdf->writeHTMLCell(95, 5, 110, 75, $sHtml1, 0, 1, false, true, "L", true); $oPdf->writeHTMLCell(60, 10, "", 150, "<strong>{$oOrderJournal->call_id}</strong>", 0, 0, false, true, "L", true); $oPdf->writeHTMLCell(120, 10, "", "", "ZAKŁADKA ZAMÓWIENIA KOPII", 0, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Numer zamówienia: <strong>{$oOrderJournal->id}</strong>", 0, 0, false, true, "L", true); $oPdf->writeHTMLCell(75, 5, "", "", "Sygnatura: <strong>{$oOrderJournal->call_id}</strong><br />Sygnatura lokalna: <strong>{$oOrderJournal->csa_call_id}</strong><br />Kolekcja: <strong>{$oOrderJournal->collection}</strong>", 0, 1, false, true, "R", true); $oPdf->writeHTMLCell(190, 5, "", "", "", 0, 1, false, true, "L", true); $oPdf->writeHTMLCell(190, 5, "", "", "", 0, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 30, "", "", "Tytuł książki / czasopisma:<br /><strong>{$oOrderJournal->journal_title}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Rocznik: <strong>{$oOrderJournal->journal_year_publication}</strong>", 1, 1, false, true, "L", true); $oPdf->writeHTMLCell(95, 5, "", "", "Numeracja: <strong>{$oOrderJournal->journal_number}</strong>", 1, 1, false, true, "L", true); $sHtml2 = "\n Data zamówienia: <strong>{$sCurrTime}</strong><br /><br />\n Zamówione dla: <br /><strong></strong>\n "; $oPdf->writeHTMLCell(95, 5, 110, 190, $sHtml2, 0, 1, false, true, "L", true); $oPdf->Output($nOrderId . ".pdf", "I"); $nOrderChangeLogId = $oModelOrderChangeLog->addRow(array("order_change_type_id" => 3, "user_id" => $this->_oAuth->getStorage()->read()->user_id, "date" => time())); $oModelOrderJournalOrderChangeLog->addRow(array("order_journal_id" => $nOrderId, "order_change_log_id" => $nOrderChangeLogId)); } exit; }
public function testPdfOutput() { $this->markTestIncomplete('Ae fonts are not part of this repository.'); // 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 018'); $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 . ' 018', PDF_HEADER_STRING); // 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 data: $lg = array(); $lg['a_meta_charset'] = 'UTF-8'; $lg['a_meta_dir'] = 'rtl'; $lg['a_meta_language'] = 'fa'; $lg['w_page'] = 'page'; // set some language-dependent strings (optional) $pdf->setLanguageArray($lg); // --------------------------------------------------------- // set font $pdf->SetFont('dejavusans', '', 12); // add a page $pdf->AddPage(); // Persian and English content $htmlpersian = '<span color="#660000">Persian example:</span><br />سلام بالاخره مشکل PDF Ùارسی به طور کامل ØÙ„ شد. اینم یک نمونش.<br />مشکل Øر٠\\"Ú˜\\" در بعضی کلمات مانند کلمه ویژه نیز بر طر٠شد.<br />نگارش Øرو٠لام Ùˆ ال٠پشت سر هم نیز تصØÛŒØ Ø´Ø¯.<br />با تشکر از "Asuni Nicola" Ùˆ Ù…Øمد علی Ú¯Ù„ کار برای پشتیبانی زبان Ùارسی.'; $pdf->WriteHTML($htmlpersian, true, 0, true, 0); // set LTR direction for english translation $pdf->setRTL(false); $pdf->SetFontSize(10); // print newline $pdf->Ln(); // Persian and English content $htmlpersiantranslation = '<span color="#0000ff">Hi, At last Problem of Persian PDF Solved completely. This is a example for it.<br />Problem of "jeh" letter in some word like "ویژه" (=special) fix too.<br />The joining of laa and alf letter fix now.<br />Special thanks to "Nicola Asuni" and "Mohamad Ali Golkar" for Persian support.</span>'; $pdf->WriteHTML($htmlpersiantranslation, true, 0, true, 0); // Restore RTL direction $pdf->setRTL(true); // set font $pdf->SetFont('aefurat', '', 18); // print newline $pdf->Ln(); // Arabic and English content $pdf->Cell(0, 12, 'بÙسْم٠الله٠الرَّØْمن٠الرَّØÙيمÙ', 0, 1, 'C'); $htmlcontent = 'تمَّ بÙØمد الله Øلّ مشكلة الكتابة باللغة العربية ÙÙŠ ملÙات الـ<span color="#FF0000">PDF</span> مع دعم الكتابة <span color="#0000FF">من اليمين إلى اليسار</span> Ùˆ<span color="#009900">الØركَات</span> .<br />تم الØÙ„ بواسطة <span color="#993399">ØµØ§Ù„Ø Ø§Ù„Ù…Ø·Ø±ÙÙŠ Ùˆ Asuni Nicola</span> . '; $pdf->WriteHTML($htmlcontent, true, 0, true, 0); // set LTR direction for english translation $pdf->setRTL(false); // print newline $pdf->Ln(); $pdf->SetFont('aealarabiya', '', 18); // Arabic and English content $htmlcontent2 = '<span color="#0000ff">This is Arabic "العربية" Example With TCPDF.</span>'; $pdf->WriteHTML($htmlcontent2, true, 0, true, 0); $this->comparePdfs($pdf); }
/** * Draw a box to put the barcodes. * * @param TCPDF &$pdf * @param $marksize * @param &$dims * @param $label='0' * @param $name * @param $fill=false * * @return $object with a coords and marks properties */ function blended_draw_barcode_placeholder(TCPDF &$pdf, $marksizew, $marksizeh, &$dims, $label = '0', $name, $fill = false) { $fontsize = $pdf->getFontSizePt(); $pdf->SetFontSize(4); blended_saveXY($dims, $pdf); $render = $fill ? 'F' : 'D'; $pdf->Cell($marksizew, $marksizeh, $label, 1, 0, 'C', $fill, '', ''); // $pdf->SetFillColor(0,0,0); //$pdf->Rect($pdf->getX(),$pdf->getY(),$marksizew,$marksizeh,$render); //label mark inside $pdf->SetFontSize($fontsize); blended_saveWH($dims, $pdf); //store mark coords blended_saveBarCode($dims, $name); }
$bik = stripslashes($_POST['bik']); $correspondent_account = stripslashes($_POST['correspondent_account']); $banknote = stripslashes($_POST['banknote']); $pence = stripslashes($_POST['pence']); $order_id = stripslashes($_POST['order_id']); $amount = stripslashes($_POST['amount']); //set document properties $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->setPageOrientation('P'); //set font for the entire document $pdf->SetTextColor(0, 0, 0); //set up a page $pdf->AddPage(); $pdf->SetDisplayMode('real'); $pdf->SetFontSize(8); // ширина квитанции $width = 190; // Высота половинки $height = 75; // ширина слушебного поля $field_width = 80; // Начальные координаты $x = 10; $y = 10; // Первая рамка $pdf->SetLineStyle(array('dash' => 2)); $pdf->SetXY($x, $y); $pdf->Cell($width, $height, '', 1, 0, 'C', 0); $pdf->SetXY($field_width + $x - 40, $y + 5); $pdf->Write(5, "Извещение" . PHP_EOL);
/** * Adds to the TCPDF instance, the data related to a row in the GIS dataset. * * @param string $spatial GIS LINESTRING object * @param string $label Label for the GIS LINESTRING object * @param string $line_color Color for the GIS LINESTRING object * @param array $scale_data Array containing data related to scaling * @param TCPDF $pdf TCPDF instance * * @return TCPDF the modified TCPDF instance * @access public */ public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf) { /** @var PMA_String $pmaString */ $pmaString = $GLOBALS['PMA_String']; // allocate colors $red = hexdec($pmaString->substr($line_color, 1, 2)); $green = hexdec($pmaString->substr($line_color, 3, 2)); $blue = hexdec($pmaString->substr($line_color, 4, 2)); $line = array('width' => 1.5, 'color' => array($red, $green, $blue)); // Trim to remove leading 'LINESTRING(' and trailing ')' $linesrting = $pmaString->substr($spatial, 11, $pmaString->strlen($spatial) - 12); $points_arr = $this->extractPoints($linesrting, $scale_data); foreach ($points_arr as $point) { if (!isset($temp_point)) { $temp_point = $point; } else { // draw line section $pdf->Line($temp_point[0], $temp_point[1], $point[0], $point[1], $line); $temp_point = $point; } } // print label if (isset($label) && trim($label) != '') { $pdf->SetXY($points_arr[1][0], $points_arr[1][1]); $pdf->SetFontSize(5); $pdf->Cell(0, 0, trim($label)); } return $pdf; }
$penduduk = new AktaLoader($id); $penduduk->retrieve_data(); $pdf = new TCPDF("P", PDF_UNIT, "A4", true, "UTF-8", false); $pdf->SetMargins(10, 20, 10); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->setPrintFooter(false); $pdf->setPrintHeader(false); $pdf->SetTitle("Akta Kelahiran"); $pdf->SetAutoPageBreak(true, 10); $pdf->AddPage(); // -------- $pdf->SetFont("times", '', 12); $pdf->Cell(130, 1, "Nomor Induk Kependudukan", 0, 0, 'L', 0); $pdf->Cell(70, 1, $penduduk->nik, 0, 0, 'L', 0); $pdf->Ln(40); $pdf->SetFontSize(18); $pdf->MultiCell(200, 1, "PENCATATAN SIPIL", 0, 'C', 0, 1, '', '', true); if (strcmp($penduduk->wni, 'WNI') == 0) { $pdf->MultiCell(200, 1, "WARGA NEGARA: INDONESIA", 0, 'C', 0, 1, '', '', true); } else { $pdf->MultiCell(200, 1, "WARGA NEGARA: ASING", 0, 'C', 0, 1, '', '', true); } $pdf->MultiCell(200, 1, "KUTIPAN AKTA KELAHIRAN", 0, 'C', 0, 1, '', '', true); $pdf->Ln(40); $tangal_lahir = strtotime($penduduk->tanggal_lahir); $pdf->SetFontSize(12); $pdf->Write(1, "Berdasarkan Akta Kelahiran Nomor ...............{$penduduk->no_akta} ........", '', 0, 'L', true); $pdf->Write(1, "menurut stbld ..................... - ..........................", '', 0, 'L', true); $pdf->Write(1, "bahwa di ....{$penduduk->tempat_lahir} .... pada tanggal ..." . strftime(date('d F', $tangal_lahir)) . " tahun " . strftime(date('Y', $tangal_lahir)) . " telah lahir", '', 0, 'L', true); $pdf->MultiCell(150, 1, " ---- " . strtoupper($penduduk->nama) . " ----", 0, 'C', 0, 1, '', '', true); $pdf->Write(1, "anak {$penduduk->jenis_kelamin}, dari suami-istri ", '', 0, 'L', true);
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 024'); $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 . ' 024', PDF_HEADER_STRING); // 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 font $pdf->SetFont('times', '', 18); // add a page $pdf->AddPage(); /* * setVisibility() allows to restrict the rendering of some * elements to screen or printout. This can be useful, for * instance, to put a background image or color that will * show on screen but won't print. */ $txt = 'You can limit the visibility of PDF objects to screen or printer by using the setVisibility() method. Check the print preview of this document to display the alternative text.'; $pdf->Write(0, $txt, '', 0, '', true, 0, false, false, 0); // change font size $pdf->SetFontSize(40); // change text color $pdf->SetTextColor(0, 63, 127); // set visibility only for screen $pdf->setVisibility('screen'); // write something only for screen $pdf->Write(0, '[This line is for display]', '', 0, 'C', true, 0, false, false, 0); // set visibility only for print $pdf->setVisibility('print'); // change text color $pdf->SetTextColor(127, 0, 0); // write something only for print $pdf->Write(0, '[This line is for printout]', '', 0, 'C', true, 0, false, false, 0); // restore visibility $pdf->setVisibility('all'); // --------------------------------------------------------- // LAYERS // start a new layer $pdf->startLayer('layer1', true, true); // change font size $pdf->SetFontSize(18); // change text color $pdf->SetTextColor(0, 127, 0); $txt = 'Using the startLayer() method you can group PDF objects into layers. This text is on "layer1".'; // write something $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); // close the current layer $pdf->endLayer(); $this->comparePdfs($pdf); }
/** * Adds to the TCPDF instance, the data related to a row in the GIS dataset. * * @param string $spatial GIS MULTIPOLYGON object * @param string $label Label for the GIS MULTIPOLYGON object * @param string $fill_color Color for the GIS MULTIPOLYGON object * @param array $scale_data Array containing data related to scaling * @param TCPDF $pdf TCPDF instance * * @return TCPDF the modified TCPDF instance * @access public */ public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf) { /** @var PMA_String $pmaStr */ $pmaStr = $GLOBALS['PMA_String']; // allocate colors $red = hexdec($pmaStr->substr($fill_color, 1, 2)); $green = hexdec($pmaStr->substr($fill_color, 3, 2)); $blue = hexdec($pmaStr->substr($fill_color, 4, 2)); $color = array($red, $green, $blue); // Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))' $multipolygon = $pmaStr->substr($spatial, 15, $pmaStr->strlen($spatial) - 18); // Separate each polygon $polygons = explode(")),((", $multipolygon); $first_poly = true; foreach ($polygons as $polygon) { // If the polygon doesn't have an inner polygon if ($pmaStr->strpos($polygon, "),(") === false) { $points_arr = $this->extractPoints($polygon, $scale_data, true); } else { // Separate outer and inner polygons $parts = explode("),(", $polygon); $outer = $parts[0]; $inner = array_slice($parts, 1); $points_arr = $this->extractPoints($outer, $scale_data, true); foreach ($inner as $inner_poly) { $points_arr = array_merge($points_arr, $this->extractPoints($inner_poly, $scale_data, true)); } } // draw polygon $pdf->Polygon($points_arr, 'F*', array(), $color, true); // mark label point if applicable if (isset($label) && trim($label) != '' && $first_poly) { $label_point = array($points_arr[2], $points_arr[3]); } $first_poly = false; } // print label if applicable if (isset($label_point)) { $pdf->SetXY($label_point[0], $label_point[1]); $pdf->SetFontSize(5); $pdf->Cell(0, 0, trim($label)); } return $pdf; }
require_once '../../vendor/tcpdf_min/tcpdf.php'; $post = $_POST['post']; //TODO first // sort seats // $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, [82, 51], true, 'UTF-8', false); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->SetMargins(0, 0, 0, true); $pdf->SetAutoPageBreak(true, 0); foreach ($post['seats'] as $k => $v) { $pdf->AddPage('L'); //lien 1 $pdf->SetFont('courier', 'B'); $pdf->SetFontSize(8); $pdf->Text(0, 0, $post['showtime']['shortTitle']); $pdf->Text(0, 3, date('d m Y', strtotime($post['showtime']['date']))); $pdf->Text(20, 3, date('H:i', mktime(0, $post['showtime']['start']))); $pdf->Text(0, 6, 'seat: ' . $k); $pdf->Text(18, 6, $v['type']); $pdf->Text(0, 9, 'room: ' . $post['showtime']['room']); $pdf->Text(0, 12, 'Adult'); $pdf->Text(0, 15, $v['price']); $pdf->Text(0, 18, $post['profile']['fullName']); //lien 2 $pdf->SetFontSize(14); $pdf->Text(34, 0, $post['showtime']['shortTitle']); $pdf->SetFontSize(10); $pdf->Text(34, 5, date('d m Y', strtotime($post['showtime']['date']))); $pdf->SetFontSize(14);
public function add_font() { require_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php'; require APPPATH . 'libraries/tcpdf/tcpdf.php'; error_reporting(1); $fontMaker = new TCPDF_FONTS(); $font = $fontMaker->addTTFfont($_SERVER['DOCUMENT_ROOT'] . 'js/TEMPSITC_new.TTF'); $pdfMaker = new TCPDF('L', 'mm', 'A4', true, 'utf-8'); $pdfMaker->AddPage('L'); $pdfMaker->SetMargins(0, 0, 0, true); $pdfMaker->SetFont($font); $pdfMaker->SetFontSize('20'); $pdfMaker->SetTextColor(0, 0, 0); $pdfMaker->Text(10, 10, 'Hello!'); echo '<pre>'; print_r($font); echo ':)</pre>'; //$pdfMaker->Output(); }
$pdf->setPage(1); for ($r = 0; $r < $rows; $r++) { // Calculate the correct position on the page, and move to it $posX = $marginPageLeft + $c * ($spacingCol + $wLabel); $posY = $marginPageTop + $r * ($spacingRow + $hLabel); $pdf->SetXY($posX, $posY); // Truncate text to maximum allowed $txt = $prefix . sprintf("%0" . strlen($startno) . "d", $iStartNo++); $txt = substr($txt, 0, $tape == 'dlt' ? 8 : 6); if ($borders) { $pdf->RoundedRect($posX, $posY, $wLabel, $hLabel, $radius); } // Print contents of boxes if ($textOrientation == 'vertical') { // Set a proper font size $pdf->SetFontSize($fontSize * 1.6); // begin at bottom left, and start a rotation $pdf->SetXY($posX + $radius, $posY + $hLabel); $pdf->StartTransform(); $pdf->Rotate(90); } else { // Set a proper font size $pdf->SetFontSize($fontSize * 1.2); $pdf->SetXY($posX + $radius, $posY + $hBarcode + $paddingTop); } $pdf->SetFillColor(192, 128, 255); foreach (str_split($txt) as $letter) { $pdf->SetFillColorArray($colorized && is_numeric($letter) ? $aColors[$letter] : array(255, 255, 255)); if ($textOrientation == 'vertical') { $pdf->Cell($hBox, $wBox, $letter, 1, 2, 'C', true, '', 0, true); } else {
function writeDetalles(DataSource $dataSource, TCPDF $pdf, $tipo) { $blackAll = array('LTRB' => array('width' => 0.3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); $widthMarginLeft = 1; $width1 = 20; $width2 = 130; $pdf->Ln(); $pdf->SetFontSize(7.5); $pdf->SetFont('', 'B'); $height = 5; $pdf->SetFillColor(255, 255, 255, true); $pdf->setTextColor(0, 0, 0); $pdf->Cell($width1 - 5, $height, 'Cantidad', $blackAll, 0, 'L', true, '', 1, false, 'T', 'C'); if ($tipo == 'Bien') { $pdf->Cell($width2, $height, 'Item', $blackAll, 0, 'l', true, '', 1, false, 'T', 'C'); } else { if ($tipo == 'Bien - Servicio') { $pdf->Cell($width2, $height, 'Compra-Servicio', $blackAll, 0, 'l', true, '', 1, false, 'T', 'C'); } else { $pdf->Cell($width2, $height, 'Servicio', $blackAll, 0, 'l', true, '', 1, false, 'T', 'C'); } } $pdf->Cell($width1, $height, 'Precio Unitario', $blackAll, 0, 'C', true, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, 'Total Bs.', $blackAll, 0, 'C', true, '', 1, false, 'T', 'C'); $pdf->Ln(); $pdf->SetFontSize(6.5); $totalOrdenCompra = 0.0; foreach ($dataSource->getDataset() as $row) { $pdf->SetFont('', ''); //$totalItem $pdf->Cell($width1 - 5, $height, $row['cantidad_adju'], 1, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width2, $height, $row['desc_solicitud_det'], 1, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, number_format($row['precio_unitario'], 2), 1, 0, 'R', false, '', 1, false, 'T', 'C'); $totalItem = $row['cantidad_adju'] * $row['precio_unitario']; $pdf->Cell($width1, $height, number_format($totalItem, 2), 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Ln(); //var_dump($totalItem+$totalOrdenCompra); $totalOrdenCompra = $totalOrdenCompra + $totalItem; //var_dump($totalOrdenCompra); $obj = new Numbers_Words_es_AR(); $numero = explode('.', number_format($totalItem, 2)); $pdf->Cell($width2 + $width1 + $width1 / 2 + $width1 / 4, $height, 'SON: ' . strtoupper(trim($obj->toWords(str_replace(',', '', $numero[0])))) . ' ' . $numero[1] . '/' . '100 ' . strtoupper($this->getDataSource()->getParameter('moneda')), 1, 0, 'L', false, '', 1, false, 'T', 'C'); } $pdf->Cell($width1, $height, number_format($totalOrdenCompra, 2), 1, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Ln(); }
protected function btnPrint_Click() { if ($this->lstLabelStock->SelectedValue) { $this->lstLabelStock->Warning = ""; set_time_limit(0); // If the user clicked Cancel button if ($_SESSION["intGeneratingStatus"] != -1) { // If the user clicked outside of the modal dialog if ($this->dlgPrintLabels->Visible && $this->dlgPrintLabels->Display) { if ($this->intCurrentBarCodeLabel < count($this->strBarCodeArray)) { array_push($this->strTablesBufferArray, $this->CreateTableByBarCodeArray()); $this->txtWarning->Text = "Please wait... PDF Generating: " . $_SESSION["intGeneratingStatus"] . "% Complete"; $this->txtWarning->Display = true; $this->btnPrint->Enabled = true; QApplication::ExecuteJavaScript("document.getElementById('" . $this->btnPrint->ControlId . "').click();"); } else { include_once '../includes/php/tcpdf/config/lang/eng.php'; include_once '../includes/php/tcpdf/tcpdf.php'; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); // Set document information $pdf->SetCreator("Tracmor"); $pdf->SetAuthor("Tracmor"); $pdf->SetTitle("Bar Codes"); // Set PDF viewer preferences $arrPreferences = array('PrintScaling' => 'None'); $pdf->setViewerPreferences($arrPreferences); // Disable header and footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // Disable auto page breaks $pdf->SetAutoPageBreak(false); // Set some language-dependent strings $pdf->setLanguageArray($l); // Set the color used for all drawing operations (lines, rectangles and cell borders). $pdf->SetDrawColor(255); // white // Set Cell Padding $pdf->SetCellPadding(0); // Set Cell Spacing $pdf->SetLineWidth(0); // Initialize document $pdf->AliasNbPages(); switch ($this->lstLabelStock->SelectedValue) { case 1: // Labels per row for Avery 6577 (5/8" x 3") $pdf->SetFontSize(3); $pdf->setCellHeightRatio(2.3); // was 1.93 // Set margins $pdf->SetMargins(12, 12, 12); break; case 2: // Labels per row for Avery 6576 (1-1/4" x 1-3/4") $pdf->SetFontSize(3); $pdf->setCellHeightRatio(11.0); // was 10.2 // Set margins $pdf->SetMargins(10, 16, 10); break; default: throw new QCallerException('Label Stock Not Provided'); break; } foreach ($this->strTablesBufferArray as $strTableBuffer) { // add a page $pdf->AddPage(); // output the HTML content $pdf->writeHTML($strTableBuffer); } // Close and save PDF document $pdf->Output(".." . __TRACMOR_TMP__ . "/" . $_SESSION['intUserAccountId'] . "_BarCodes.pdf", "F"); // Cleaning up $this->btnCancel_Click(); // Uncheck all items but SelectAll checkbox foreach ($this->GetAllControls() as $objControl) { if (substr($objControl->ControlId, 0, 11) == 'chkSelected') { $objControl->Checked = false; } } $arrDataGridObjectNameId = $this->ctlSearchMenu->GetDataGridObjectNameId(); // Uncheck SelectAll checkbox $this->ctlSearchMenu->{$arrDataGridObjectNameId}[0]->chkSelectAll->Checked = false; // Open generated PDF in new window QApplication::ExecuteJavaScript("window.open('.." . __TRACMOR_TMP__ . "/" . $_SESSION['intUserAccountId'] . "_BarCodes.pdf','Barcodes','resizeable,menubar=1,scrollbar=1,left=0,top=0,width=800,height=600');"); } } else { // Cleaning up $this->btnCancel_Click(); } } } else { $this->lstLabelStock->Warning = "Please select one"; $this->lstLabelStock->Enabled = true; } }
function writeDetalles(DataSource $dataSource, TCPDF $pdf) { $blackAll = array('LTRB' => array('width' => 0.3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); $blackSide = array('LR' => array('width' => 0.3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); $blackBottom = array('B' => array('width' => 0.3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); $blackTop = array('T' => array('width' => 0.3, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); $widthMarginLeft = 1; $width1 = 15; $width2 = 25; $width3 = 20; $pdf->SetFontSize(7.5); $pdf->SetFont('', 'B'); $height = 5; $pdf->Ln(); foreach ($dataSource->getDataset() as $row) { $pdf->setFont('', 'B'); $pdf->Cell($width2, $height, 'Código Partida', 0, 0, 'L', false, '', 0, false, 'T', 'C'); $pdf->Cell($width2, $height, 'Nombre Partida', 0, 0, 'L', false, '', 0, false, 'T', 'C'); $pdf->Cell($width2 * 3 + 10, $height, 'Centro de Costo', 0, 0, 'L', false, '', 0, false, 'T', 'C'); $pdf->Cell($width2, $height, '', 0, 0, 'R', false, '', 0, false, 'T', 'C'); $pdf->Cell($width2, $height, 'Disponibilidad', 0, 0, 'R', false, '', 0, false, 'T', 'C'); $pdf->Ln(); $pdf->setFont('', ''); $pdf->Cell($width2, $height, $row['groupeddata'][0]['codigo_partida'], 0, 0, 'L', false, '', 0, false, 'T', 'C'); $pdf->Cell($width2, $height, $row['groupeddata'][0]['nombre_partida'], 0, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width2 * 3 + 10, $height, $row['groupeddata'][0]['desc_centro_costo'], 0, 0, 'L', false, '', 1, false, 'T', 'C'); $xRef = $pdf->getX(); $yRef = $pdf->getY(); $pdf->Cell($width2, $height, $row['totalRef'], 0, 0, 'R', false, '', 0, false, 'T', 'C'); if ($row['disponible'] == true) { $pdf->setTextColor(0, 0, 0); $pdf->Cell($width2, $height, 'DISPONIBLE', 0, 0, 'R', false, '', 0, false, 'T', 'C'); } else { $pdf->setTextColor(255, 0, 0); $pdf->Cell($width2, $height, 'NO DISPONIBLE', 0, 0, 'R', false, '', 0, false, 'T', 'C'); } $pdf->setTextColor(0, 0, 0); //$pdf->Cell($width2, $height, ($row['disponible']==true)?'DISPONIBLE':'NO DISPONIBLE', 0, 0, 'R', false, '', 0, false, 'T', 'C'); $pdf->Ln(); $pdf->setFont('', 'B'); $pdf->Cell($width2 + $width1, $height, 'Concepto Gasto', $blackAll, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width2 + 25, $height, 'Descripcion', $blackAll, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, 'Cantidad', $blackAll, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, 'Precio Unitario', $blackAll, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, 'Precio Total', $blackAll, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, 'Precio Ges. Act.', $blackAll, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, 'Precio Ges. Sig.', $blackAll, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Ln(); $totalRef = 0; $totalGa = 0; $totalSg = 0; $xEnd = 0; $yEnd = 0; foreach ($row['groupeddata'] as $solicitudDetalle) { $pdf->setFont('', ''); $pdf->Cell($width2 + $width1, $height, $solicitudDetalle['desc_concepto_ingas'], $blackSide, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width2 + 25, $height, $solicitudDetalle['descripcion'], $blackSide, 0, 'L', false, '', 1, false, 'T', 'C'); $pdf->Cell($width1, $height, $solicitudDetalle['cantidad'], $blackSide, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, number_format($solicitudDetalle['precio_unitario'], 2), $blackSide, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, number_format($solicitudDetalle['precio_total'], 2), $blackSide, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, number_format($solicitudDetalle['precio_ga'], 2), $blackSide, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, number_format($solicitudDetalle['precio_sg'], 2), $blackSide, 0, 'R', false, '', 1, false, 'T', 'C'); $totalRef = $totalRef + $solicitudDetalle['precio_total']; $totalGa = $totalGa + $solicitudDetalle['precio_ga']; $totalSg = $totalSg + $solicitudDetalle['precio_sg']; $pdf->Ln(); $xEnd = $pdf->getX(); $yEnd = $pdf->getY(); } //$pdf->setXY($xRef,$yRef); //$pdf->Cell($width2, $height, $totalRef, 0, 0, 'R', false, '', 0, false, 'T', 'C'); $pdf->setXY($xEnd, $yEnd); $pdf->Cell(185, $height, '', $blackTop, 1, 'L', false, '', 0, false, 'T', 'C'); $pdf->setXY($xEnd, $yEnd); $pdf->Cell($width1 * 2 + $width2 * 2 + $width3 + 25, $height, '', '0', 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, number_format($totalRef, 2), $blackAll, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, number_format($totalGa, 2), $blackAll, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Cell($width3, $height, number_format($totalSg, 2), $blackAll, 0, 'R', false, '', 1, false, 'T', 'C'); $pdf->Ln($height * 2); } }
function CreatePDF($mysqli, $otchet) { // $rus = array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', 'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я'); // $lat = array('A', 'B', 'V', 'G', 'D', 'E', 'E', 'Gh', 'Z', 'I', 'Y', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'Ch', 'Sh', 'Sch', 'Y', 'Y', 'Y', 'E', 'Yu', 'Ya', 'a', 'b', 'v', 'g', 'd', 'e', 'e', 'gh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'ch', 'sh', 'sch', 'y', 'y', 'y', 'e', 'yu', 'ya'); //set document properties $pdf = new TCPDF('P', 'mm', 'A4', true, 'utf-8'); $pdf->SetMargins(20, 30, 20); $pdf->AddPage(); $pdf->SetFont('dejavusans', "", 10); $pdf->SetTitle($otchet); $pdf->SetXY(20, 50); $pdf->SetDrawColor(100, 100, 0); $pdf->SetTextColor(0, 0, 0); $pdf->SetDisplayMode('real', 'default'); //insert an image and make it a link ///$pdf->Image('logo.png',10,20,33,0,' ','http://www.fpdf.org/'); //display the title with a border around it $pdf->SetXY(50, 20); $pdf->Cell(130, 10, $otchet, 1, 0, 'C', 0); if ($otchet == 'Отчет по Ключевым словам') { $pdf->SetXY(50, 50); $pdf->SetFontSize(12); $pdf->MultiCell(40, 12, 'Номер категории', 1, 'C', 0); $pdf->SetXY(90, 50); $pdf->MultiCell(50, 12, 'Категория', 1, 'C', 0); $pdf->SetXY(140, 50); $pdf->MultiCell(40, 12, 'Количество просмотров', 1, 'C', 0); ///Таблица статистики $search = array(); $s = $mysqli->prepare("SELECT * FROM Category1 ORDER BY stat"); $s->execute(); $result = $s->get_result(); $y = 62; while ($obj = $result->fetch_assoc()) { $pdf->SetXY(50, $y); $pdf->SetFontSize(10); $pdf->MultiCell(40, 20, $obj['id'] . "_1", 1, 'C', 0); $pdf->SetXY(90, $y); $pdf->MultiCell(50, 20, $obj['categ'], 1, 'C', 0); $pdf->SetXY(140, $y); $pdf->MultiCell(40, 20, $obj['stat'], 1, 'C', 0); $y += 20; } $s = $mysqli->prepare("SELECT * FROM Category2 ORDER BY stat"); $s->execute(); $result = $s->get_result(); while ($obj = $result->fetch_assoc()) { $pdf->SetXY(50, $y); $pdf->SetFontSize(10); $pdf->MultiCell(40, 20, $obj['id2'] . "_2", 1, 'C', 0); $pdf->SetXY(90, $y); $pdf->MultiCell(50, 20, $obj['categ2'], 1, 'C', 0); $pdf->SetXY(140, $y); $pdf->MultiCell(40, 20, $obj['stat'], 1, 'C', 0); $y += 20; } } else { $pdf->SetXY(30, 50); $pdf->SetFontSize(12); $pdf->MultiCell(40, 10, 'Номер новости', 1, 'C', 0); $pdf->SetXY(70, 50); $pdf->MultiCell(50, 10, 'Заголовок новости', 1, 'C', 0); $pdf->SetXY(120, 50); $pdf->MultiCell(40, 10, 'Категория', 1, 'C', 0); $pdf->SetXY(160, 50); $pdf->MultiCell(30, 10, 'Статистика', 1, 'C', 0); ///Таблица статистики $sth = $mysqli->prepare("SELECT * FROM News,Category2 WHERE News.id_cat2 = Category2.id2"); $sth->execute(); $result = $sth->get_result(); $y = 60; while ($obj = $result->fetch_assoc()) { $pdf->SetXY(30, $y); $pdf->SetFontSize(10); $pdf->MultiCell(40, 20, $obj['id'], 1, 'C', 0); $pdf->SetXY(70, $y); $pdf->MultiCell(50, 20, $obj['title'] . '...', 1, 'C', 0); $pdf->SetXY(120, $y); $pdf->MultiCell(40, 20, $obj['categ2'], 1, 'C', 0); $pdf->SetXY(160, $y); $pdf->MultiCell(30, 20, $obj['colview'], 1, 'C', 0); $y += 20; } } //Output the document $pdf->OutPut('otchet.pdf'); }
/** * Adds to the TCPDF instance, the data related to a row in the GIS dataset. * * @param string $spatial GIS POINT object * @param string $label Label for the GIS POINT object * @param string $point_color Color for the GIS POINT object * @param array $scale_data Array containing data related to scaling * @param TCPDF $pdf TCPDF instance * * @return TCPDF the modified TCPDF instance * @access public */ public function prepareRowAsPdf($spatial, $label, $point_color, $scale_data, $pdf) { // allocate colors $red = hexdec(mb_substr($point_color, 1, 2)); $green = hexdec(mb_substr($point_color, 3, 2)); $blue = hexdec(mb_substr($point_color, 4, 2)); $line = array('width' => 1.25, 'color' => array($red, $green, $blue)); // Trim to remove leading 'POINT(' and trailing ')' $point = mb_substr($spatial, 6, mb_strlen($spatial) - 7); $points_arr = $this->extractPoints($point, $scale_data); // draw a small circle to mark the point if ($points_arr[0][0] != '' && $points_arr[0][1] != '') { $pdf->Circle($points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line); // print label if applicable if (isset($label) && trim($label) != '') { $pdf->SetXY($points_arr[0][0], $points_arr[0][1]); $pdf->SetFontSize(5); $pdf->Cell(0, 0, trim($label)); } } return $pdf; }