/** * Writes text at the specified x and y coordinates * * See {@link Style::munge_color()} for the format of the color array. * * @param float $x * @param float $y * @param string $text the text to write * @param string $font the font file to use * @param float $size the font size, in points * @param array $color * @param float $adjust word spacing adjustment */ function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { dompdf_debug("trace", "({$x}, {$y}, {$text}, " . basename($font) . ", {$size}, [{$color['0']}, {$color['1']}, {$color['2']}], {$adjust}, {$angle}, {$blend}, {$opacity})"); list($r, $g, $b) = $this->_get_rgb($color); $this->_pdf->SetTextColor($r, $g, $b); $this->_set_line_transparency($blend, $opacity); $this->_set_fill_transparency($blend, $opacity); $fontdata = $this->_get_font($font); $this->_pdf->SetFont($fontdata['family'], $fontdata['style'], $size, $font); //$this->_pdf->SetFontSize($size); // ??? if ($adjust > 0) { $a = explode(' ', $text); //$this->_pdf->SetXY($x - 3, $y + (self::FONT_HEIGHT_SCALE - 1) * $size); $this->_pdf->SetXY($x, $y); //$y += self::FONT_HEIGHT_SCALE * $size + 1; for ($i = 0; $i < count($a) - 1; $i++) { $this->_pdf->Write($size, $a[$i] . ' ', ''); //$this->_pdf->Text($x, $y, $a[$i].' '); $this->_pdf->SetX($this->_pdf->GetX() + $adjust); //$x += $this->_pdf->GetX() + $adjust; } $this->_pdf->Write($size, $a[$i], ''); //$this->_pdf->Text($x, $y, $a[$i].' '); } else { if ($angle != 0) { $this->_pdf->StartTransform(); //$y += self::FONT_HEIGHT_SCALE * $size; //$y += $size; $this->_pdf->Rotate(-$angle, $x, $y); $this->_pdf->Text($x, $y, $text, false, false, true, 0, 0, '', 0, '', 0, false, 'T', 'T'); $this->_pdf->StopTransform(); } else { //$pippo = $this->_pdf->getFontAscent($fontdata['family'], $fontdata['style'], $size); //$y += $pippo / 8; //$y = $y - 0.85 * $size; // + 0.8 * $size; $this->_pdf->Text($x, $y, $text, false, false, true, 0, 0, '', 0, '', 0, false, 'T', 'T'); } } }
public function testPdfOutput() { $this->markTestIncomplete('Travis failure needs further investigation. '); // 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 014'); $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 . ' 014', 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); // --------------------------------------------------------- // IMPORTANT: disable font subsetting to allow users editing the document $pdf->setFontSubsetting(false); // set font $pdf->SetFont('helvetica', '', 10, '', false); // add a page $pdf->AddPage(); /* It is possible to create text fields, combo boxes, check boxes and buttons. Fields are created at the current position and are given a name. This name allows to manipulate them via JavaScript in order to perform some validation for instance. */ // set default form properties $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128))); $pdf->SetFont('helvetica', 'BI', 18); $pdf->Cell(0, 5, 'Example of Form', 0, 1, 'C'); $pdf->Ln(10); $pdf->SetFont('helvetica', '', 12); // First name $pdf->Cell(35, 5, 'First name:'); $pdf->TextField('firstname', 50, 5); $pdf->Ln(6); // Last name $pdf->Cell(35, 5, 'Last name:'); $pdf->TextField('lastname', 50, 5); $pdf->Ln(6); // Gender $pdf->Cell(35, 5, 'Gender:'); $pdf->ComboBox('gender', 30, 5, array(array('', '-'), array('M', 'Male'), array('F', 'Female'))); $pdf->Ln(6); // Drink $pdf->Cell(35, 5, 'Drink:'); //$pdf->RadioButton('drink', 5, array('readonly' => 'true'), array(), 'Water'); $pdf->RadioButton('drink', 5, array(), array(), 'Water'); $pdf->Cell(35, 5, 'Water'); $pdf->Ln(6); $pdf->Cell(35, 5, ''); $pdf->RadioButton('drink', 5, array(), array(), 'Beer', true); $pdf->Cell(35, 5, 'Beer'); $pdf->Ln(6); $pdf->Cell(35, 5, ''); $pdf->RadioButton('drink', 5, array(), array(), 'Wine'); $pdf->Cell(35, 5, 'Wine'); $pdf->Ln(6); $pdf->Cell(35, 5, ''); $pdf->RadioButton('drink', 5, array(), array(), 'Milk'); $pdf->Cell(35, 5, 'Milk'); $pdf->Ln(10); // Newsletter $pdf->Cell(35, 5, 'Newsletter:'); $pdf->CheckBox('newsletter', 5, true, array(), array(), 'OK'); $pdf->Ln(10); // Address $pdf->Cell(35, 5, 'Address:'); $pdf->TextField('address', 60, 18, array('multiline' => true, 'lineWidth' => 0, 'borderStyle' => 'none'), array('v' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'dv' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')); $pdf->Ln(19); // Listbox $pdf->Cell(35, 5, 'List:'); $pdf->ListBox('listbox', 60, 15, array('', 'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7'), array('multipleSelection' => 'true')); $pdf->Ln(20); // E-mail $pdf->Cell(35, 5, 'E-mail:'); $pdf->TextField('email', 50, 5); $pdf->Ln(6); // Date of the day $pdf->Cell(35, 5, 'Date:'); $pdf->TextField('date', 30, 5, array(), array('v' => date('Y-m-d'), 'dv' => date('Y-m-d'))); $pdf->Ln(10); $pdf->SetX(50); // Button to validate and print $pdf->Button('print', 30, 10, 'Print', 'Print()', array('lineWidth' => 2, 'borderStyle' => 'beveled', 'fillColor' => array(128, 196, 255), 'strokeColor' => array(64, 64, 64))); // Reset Button $pdf->Button('reset', 30, 10, 'Reset', array('S' => 'ResetForm'), array('lineWidth' => 2, 'borderStyle' => 'beveled', 'fillColor' => array(128, 196, 255), 'strokeColor' => array(64, 64, 64))); // Submit Button $pdf->Button('submit', 30, 10, 'Submit', array('S' => 'SubmitForm', 'F' => 'http://localhost/printvars.php', 'Flags' => array('ExportFormat')), array('lineWidth' => 2, 'borderStyle' => 'beveled', 'fillColor' => array(128, 196, 255), 'strokeColor' => array(64, 64, 64))); // Form validation functions $js = <<<EOD function CheckField(name,message) { var f = getField(name); if(f.value == '') { app.alert(message); f.setFocus(); return false; } return true; } function Print() { if(!CheckField('firstname','First name is mandatory')) {return;} if(!CheckField('lastname','Last name is mandatory')) {return;} if(!CheckField('gender','Gender is mandatory')) {return;} if(!CheckField('address','Address is mandatory')) {return;} print(); } EOD; // Add Javascript code $pdf->IncludeJS($js); $this->comparePdfs($pdf); }
//Adress $pdf->Cell(35, 5, 'Address:'); $pdf->TextField('address', 60, 18, array('multiline' => true, 'strokeColor' => 'ltGray')); $pdf->Ln(19); //E-mail $pdf->Cell(35, 5, 'E-mail:'); $pdf->TextField('email', 50, 5, array('strokeColor' => 'ltGray')); $pdf->Ln(6); //Newsletter $pdf->Cell(35, 5, 'Receive our', 0, 1); $pdf->Cell(35, 5, 'newsletter:'); $pdf->CheckBox('newsletter', 5, true); $pdf->Ln(10); //Date of the day (determined and formatted by JS) $pdf->Write(5, 'Date: '); $pdf->TextField('date', 30, 5); $pdf->IncludeJS("getField('date').value=util.printd('dd/mm/yyyy',new Date());\n"); $pdf->Ln(); $pdf->Write(5, 'Signature:'); $pdf->Ln(3); //Button to validate and print $pdf->SetX(95); $pdf->Button('print', 20, 8, 'Print', 'Print()', array('textColor' => 'yellow', 'fillColor' => '#FF5050')); //Form validation functions $pdf->IncludeJS("\r\nfunction CheckField(name,message) {\r\n\tvar f = getField(name);\r\n\tif(f.value == '') {\r\n\t app.alert(message);\r\n\t f.setFocus();\r\n\t return false;\r\n\t}\r\n\treturn true;\r\n}\r\n\r\nfunction Print() {\r\n\t//Validation\r\n\tif(!CheckField('firstname','First name is mandatory'))\r\n\t\treturn;\r\n\tif(!CheckField('lastname','Last name is mandatory'))\r\n\t\treturn;\r\n\tif(!CheckField('gender','Gender is mandatory'))\r\n\t\treturn;\r\n\tif(!CheckField('address','Address is mandatory'))\r\n\t\treturn;\r\n\t//Print\r\n\tprint();\r\n}\r\n"); // --------------------------------------------------------- //Close and output PDF document $pdf->Output("example_014.pdf", "I"); //============================================================+ // END OF FILE //============================================================+
public function printlongtext($fontfamily, $fontstyle, $fontsize) { //$this->gotTextOverPage=false; $this->columnFooter(); $this->pageFooter(); $this->pageHeader(); $this->columnHeader(); $this->hideheader == true; $this->currentband = 'detail'; $fontfile = $this->fontdir . '/' . $fontfamily . '.php'; if (file_exists($fontfile) || $this->bypassnofont == false) { $fontfile = $this->fontdir . '/' . $arraydata["font"] . '.php'; $this->pdf->SetFont($fontfamily, $fontstyle, $fontsize, $fontfile); } else { $fontfamily = "freeserif"; if ($fontstyle == "") { $this->pdf->SetFont('freeserif', $fontstyle, $fontsize, $this->fontdir . '/freeserif.php'); } elseif ($fontstyle == "B") { $this->pdf->SetFont('freeserifb', $fontstyle, $fontsize, $this->fontdir . '/freeserifb.php'); } elseif ($fontstyle == "I") { $this->pdf->SetFont('freeserifi', $fontstyle, $fontsize, $this->fontdir . '/freeserifi.php'); } elseif ($fontstyle == "BI") { $this->pdf->SetFont('freeserifbi', $fontstyle, $fontsize, $this->fontdir . '/freeserifbi.php'); } elseif ($fontstyle == "BIU") { $this->pdf->SetFont('freeserifbi', "BIU", $fontsize, $this->fontdir . '/freeserifbi.php'); } elseif ($fontstyle == "U") { $this->pdf->SetFont('freeserif', "U", $fontsize, $this->fontdir . '/freeserif.php'); } elseif ($fontstyle == "BU") { $this->pdf->SetFont('freeserifb', "U", $fontsize, $this->fontdir . '/freeserifb.php'); } elseif ($fontstyle == "IU") { $this->pdf->SetFont('freeserifi', "IU", $fontsize, $this->fontdir . '/freeserifbi.php'); } } //$this->pdf->SetFont($fontfamily,$fontstyle,$fontsize,$this->fontdir.'/'.$fontfamily.'php'); $this->pdf->SetTextColor($this->forcetextcolor_r, $this->forcetextcolor_g, $this->forcetextcolor_b); //$this->pdf->SetTextColor(44,123,4); $this->pdf->SetFillColor($this->forcefillcolor_r, $this->forcefillcolor_g, $this->forcefillcolor_b); $bltxt = $this->continuenextpageText; // print_r($this->continuenextpageText); // echo "longtext:$fontfamily,$fontstyle,$fontsize<br/><br/>"; $this->pdf->SetY($this->arraypageHeader[0]["height"] + $this->columnheaderbandheight + $this->arrayPageSetting["topMargin"]); $this->pdf->SetX($bltxt['x']); $maxheight = $this->arrayPageSetting["pageHeight"] - $this->arraypageFooter[0]["height"] - $this->pdf->GetY() - $bltxt['height']; $this->pdf->MultiCell($bltxt['width'], $bltxt['height'], $bltxt['txt'], $bltxt['border'], $bltxt['align'], $bltxt['fill'], $bltxt['ln'], '', '', $bltxt['reset'], $bltxt['streth'], $bltxt['ishtml'], $bltxt['autopadding'], $maxheight - $bltxt['height'], $bltxt['valign']); if ($this->pdf->balancetext != '') { $this->continuenextpageText = array('width' => $bltxt["width"], 'height' => $bltxt["height"], 'txt' => $this->pdf->balancetext, 'border' => $bltxt["border"], 'align' => $bltxt["align"], 'fill' => $bltxt["fill"], 'ln' => 1, 'x' => $bltxt['x'], 'y' => '', 'reset' => true, 'streth' => 0, 'ishtml' => false, 'autopadding' => true, 'valign' => $bltxt['valign']); $this->pdf->balancetext = ''; $this->printlongtext($fontfamily, $fontstyle, $fontsize); } //echo $this->currentband; if ($this->pdf->balancetext == '' && $this->currentband == 'detail') { if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] == '') { $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY(); } else { if ($this->maxpagey['page_' . ($this->pdf->getPage() - 1)] < $this->pdf->GetY()) { $this->maxpagey['page_' . ($this->pdf->getPage() - 1)] = $this->pdf->GetY(); } } } }
$fill = 0; $x_init = $x; $pdf->SetXY($x_init, $y); $max_rows = 1; foreach ($pdfdata as $rows) { $lc = array(); for ($i = 0; $i < count($rows); $i++) { $lc[] = $pdf->getNumLines($rows[$i], $w[$i]); } //Max no of Lines the row occupies $linecount = max($lc); for ($i = 0; $i < count($rows); $i++) { $pdf->MultiCell($w[$i], $header_h * $linecount + $header_h, trim($rows[$i]) . "\n", 0, 'J', 0, 0, $x_init, $y, true); //$pdf->writeHTMLCell($w[$i], $row_height, $x_init, $y,$rows[$i]."\n",0,0,0); $x_init = $x_init + $w[$i]; $pdf->SetX($x_init); } // Line break - Line X $y = $y + $header_h * $linecount + $header_h; if ($y > $y_max) { $pdf->AddPage(); $y = $y_start; } $x_init = $x; $pdf->SetXY($x_init, $y); $fill = !$fill; } // --------------------------------------------------------- ob_end_clean(); //Close and output PDF document $pdf->Output("Report.pdf", "I");
$pdf->Cell(35, 5, 'Address:'); $pdf->TextField('address', 60, 18, array('multiline' => true, 'lineWidth' => 0, 'borderStyle' => 'none'), array('v' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'dv' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.')); $pdf->Ln(19); // Listbox $pdf->Cell(35, 5, 'List:'); $pdf->ListBox('listbox', 60, 15, array('', 'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7'), array('multipleSelection' => 'true')); $pdf->Ln(20); // E-mail $pdf->Cell(35, 5, 'E-mail:'); $pdf->TextField('email', 50, 5); $pdf->Ln(6); // Date of the day $pdf->Cell(35, 5, 'Date:'); $pdf->TextField('date', 30, 5, array(), array('v' => date('Y-m-d'), 'dv' => date('Y-m-d'))); $pdf->Ln(10); $pdf->SetX(50); // Button to validate and print $pdf->Button('print', 30, 10, 'Print', 'Print()', array('lineWidth' => 2, 'borderStyle' => 'beveled', 'fillColor' => array(128, 196, 255), 'strokeColor' => array(64, 64, 64))); // Reset Button $pdf->Button('reset', 30, 10, 'Reset', array('S' => 'ResetForm'), array('lineWidth' => 2, 'borderStyle' => 'beveled', 'fillColor' => array(128, 196, 255), 'strokeColor' => array(64, 64, 64))); // Submit Button $pdf->Button('submit', 30, 10, 'Submit', array('S' => 'SubmitForm', 'F' => 'http://localhost/printvars.php', 'Flags' => array('ExportFormat')), array('lineWidth' => 2, 'borderStyle' => 'beveled', 'fillColor' => array(128, 196, 255), 'strokeColor' => array(64, 64, 64))); // Form validation functions $js = <<<EOD function CheckField(name,message) { \tvar f = getField(name); \tif(f.value == '') { \t app.alert(message); \t f.setFocus(); \t return false; \t}
/** * we redifine the original SetX method, because we don't want the automatic treatment. * It is HTML2PDF that make the treatment. * If language is RTL direction this method will call to parent (TCPDF class). * * @param float $x * @param boolean $rtloff * @access public */ public function SetX($x, $rtloff=false) { if (!$rtloff AND $this->rtl) { parent::SetX($x, $rtloff); } else { $this->x=$x; } }
public function tax_continuous_type4($id = null, $year = null) { if (Session::get('level') != '') { $y = Input::get('y3'); if ($y != '') { $year = $y; $id = 'all'; } $pdf = new TCPDF(); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $n = DB::select('select * from s_general_data'); foreach ($n as $k) { $name = $k->name; $address = $k->address; $address2 = $k->address2; $tax_id2 = $k->tax_id2; $director = $k->director; } $sql = ' select concat(n.pname,"",n.fname," ",n.lname) as name, s.cid, s.tax_id,sum(s.salary+s.r_other) as salary, sum(s.r_c) as r_c, sum(s.special_m+s.pts+s.pts2) as special, sum(s.tax) as tax ,sum(s.kbk) as kbk from s_salary_ocsc_detail s left join n_datageneral n on n.cid=s.cid left join n_position_salary p on p.cid=n.cid where s.cid=5350400051484 and year(s.order_date)=' . $year . ' group by s.cid order by n.datainfoID asc '; $result = DB::select($sql); foreach ($result as $key) { $pdf->AddPage('P', 'A4'); $pdf->SetFont('freeserif', 'B', 11, '', true); $pdf->MultiCell(185, 5, 'เลขที่ งป. ........................./ ' . ($year == 'null' ? $this->yearThai() : $year + 543), 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 16, '', true); $pdf->SetY(25); $pdf->SetX(18); $pdf->MultiCell(177, 5, 'หนังสือรับรองการหักภาษี ณ ที่จ่าย', 0, 'C', 0, 1, '', '', true); $pdf->SetY(34); $pdf->SetX(18); $pdf->MultiCell(177, 5, 'ตามมาตรา 50 ทวิ แห่งประมวลรัษฎากร', 0, 'C', 0, 1, '', '', true); //===== แนวตั้ง =====// $linever1 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 190, 18, 50, $linever1); $linever2 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(80, 190, 80, 50, $linever2); $linever3 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(110, 190, 110, 50, $linever3); $linever4 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(135, 190, 135, 50, $linever4); $linever5 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(165, 190, 165, 50, $linever5); $linever6 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(195, 190, 195, 50, $linever6); //===== แนวนอน =====// $linetop = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 50, 195, 50, $linetop); $linetop2 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(80, 63, 195, 63, $linetop2); $linetop3 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 120, 80, 120, $linetop3); $linetop4 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(80, 180, 195, 180, $linetop4); $linetop5 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(18, 190, 195, 190, $linetop5); //======= text in box 1 ========// $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(52); $pdf->SetX(19); $pdf->MultiCell(62, 5, 'ชื่อและที่อยู่ของผู้มีหน้าที่หักภาษี ณ ที่จ่าย บุคคลคณะบุคคล นิติบุคคล ส่วนราชการ องค์การ รัฐวิสาหกิจ ฯลฯ ', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(82); $pdf->SetX(19); $pdf->MultiCell(62, 5, $address2, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(105); $pdf->SetX(19); $pdf->MultiCell(40, 5, $tax_id2, 0, 'L', 0, 1, '', '', true); //======= text in box 2 ========// $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(122); $pdf->SetX(19); $pdf->MultiCell(62, 5, 'ชื่อและที่อยู่ของผู้ถูกหักภาษี ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 12, '', true); $pdf->SetY(137); $pdf->SetX(21); $pdf->MultiCell(59, 5, $key->name, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(145); $pdf->SetX(19); $pdf->MultiCell(62, 5, $address, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(165); $pdf->SetX(19); $pdf->MultiCell(62, 5, 'เลขประจำตัวผู้เสียภาษีของผู้ถูกหักภาษี ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(178); $pdf->SetX(22); $pdf->MultiCell(62, 5, $key->cid, 0, 'L', 0, 1, '', '', true); //======= text in box 3 header content ========// $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(83); $pdf->MultiCell(32, 5, 'เงินได้ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(111); $pdf->MultiCell(32, 5, 'ปีภาษีที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(138); $pdf->MultiCell(32, 5, 'จำนวนเงิน', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(54); $pdf->SetX(167); $pdf->MultiCell(32, 5, 'ภาษีที่หักไว้', 0, 'L', 0, 1, '', '', true); //============= text in content ================// $pdf->SetFont('freeserif', '', 12, '', true); //-----col 1 $pdf->SetY(70); $pdf->SetX(80); $pdf->MultiCell(30, 5, 'เงินเดือน ค่าจ้าง บำนาญ เบี้ยเลี้ยง โบนัส ตามมาตรา 40(1)', 0, 'L', 0, 1, '', '', true); $pdf->SetY(95); $pdf->SetX(80); $pdf->MultiCell(31, 5, 'เงินประจำตำแหน่ง', 0, 'L', 0, 1, '', '', true); $pdf->SetY(104); $pdf->SetX(80); $pdf->MultiCell(27, 5, 'เงินค่าตอบแทนพิเศษ พตส ค่าครองชีพ', 0, 'L', 0, 1, '', '', true); //-----col 2 $pdf->SetY(70); $pdf->SetX(116); $pdf->MultiCell(31, 5, $year == 'null' ? $this->yearThai() : $year + 543, 0, 'L', 0, 1, '', '', true); //-----col 3 $pdf->SetY(70); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->salary, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(95); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->r_c, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(104); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->special, 2), 0, 'R', 0, 1, '', '', true); //-----col 4 $pdf->SetY(70); $pdf->SetX(165); $pdf->MultiCell(30, 5, number_format($key->tax, 2), 0, 'R', 0, 1, '', '', true); //============= text in box 4 footer sum ============// $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(182); $pdf->SetX(89); $pdf->MultiCell(32, 5, 'รวม', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(182); $pdf->SetX(135); $pdf->MultiCell(30, 5, number_format($key->salary + $key->special + $key->r_c, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(182); $pdf->SetX(165); $pdf->MultiCell(30, 5, number_format($key->tax, 2), 0, 'R', 0, 1, '', '', true); //============= text footer ================// $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(195); $pdf->SetX(22); $pdf->MultiCell(32, 5, 'ผู้จ่ายเงิน', 0, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(39); $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(44); $pdf->MultiCell(30, 5, '(1) หัก ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(73); $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(78); $pdf->MultiCell(35, 5, '(2) ออกให้ตลอดไป', 0, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(112); $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true); $pdf->SetY(195); $pdf->SetX(117); $pdf->MultiCell(35, 5, '(3) ออกให้ครั้งเดียว', 0, 'L', 0, 1, '', '', true); $pdf->SetY(205); $pdf->SetX(39); $pdf->MultiCell(5, 5, ' /', 1, 'L', 0, 1, '', '', true); $pdf->SetY(205); $pdf->SetX(44); $pdf->MultiCell(100, 5, '(4) เงินสบทบกองทุนประกันสังคม ' . ' ' . number_format($key->kbk, 2) . ' บาท', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 12, '', true); $pdf->SetY(220); $pdf->SetX(18); $pdf->MultiCell(177, 5, 'ข้าพเจ้าขอรับรองว่า ข้อความและตัวเลขดังกล่าวข้างต้นนี้ถูกต้องตามความเป็นจริงทุกประการ', 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(235); $pdf->SetX(32); $pdf->MultiCell(170, 5, 'ลงชื่อ...........................................................ผู้มีหน้าที่หักภาษี ณ ที่จ่าย', 0, 'C', 0, 1, '', '', true); $pdf->SetY(245); $pdf->SetX(32); $pdf->MultiCell(140, 5, $director, 0, 'C', 0, 1, '', '', true); $pdf->SetY(255); $pdf->SetX(32); $pdf->MultiCell(140, 5, 'ทันตแพทย์เชี่ยวชาญ ปฎิบัติราชการแทน', 0, 'C', 0, 1, '', '', true); $pdf->SetY(265); $pdf->SetX(32); $pdf->MultiCell(140, 5, 'ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'C', 0, 1, '', '', true); } $filename = storage_path() . '/report_tax_continuous_emp4.pdf'; // Response::download($filename); $contents = $pdf->output($filename, 'I'); $headers = array('Content-Type' => 'application/pdf'); return Response::make($contents, 200, $headers); } else { return View::make('login.index'); } }
$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 { $pdf->Cell($wBox, $hBox, $letter, 1, 0, 'C', true, '', 0, true); } } if ($textOrientation == 'vertical') { $pdf->StopTransform(); } // Print media name in a box of its own if ($tape != 'dlt') { $pdf->SetFontSize($fontSize); if ($textOrientation == 'vertical') { // begin at bottom left, and start a rotation $pdf->SetXY($posX + $radius + $wBox * 6, $posY + $hLabel); $pdf->StartTransform(); $pdf->Rotate(90); $pdf->Cell($hBox, $wBox, strtoupper($tape), 1, 0, 'C', false, '', 0, true); $pdf->StopTransform(); } else { $pdf->SetX($posX + $radius + $wBox * 6); $pdf->Cell($wBox, $hBox, strtoupper($tape), 1, 0, 'C', false, '', 0, true); } $txt .= strtoupper($tape); } // Finish with the actual barcode $pdf->write1DBarcode($txt, 'C39', $posX, $posY + $paddingTop, $wLabel, $hBarcode, '', $style); } } $pdf->Output('barcodes.pdf', 'D');
$q=mysql_query("SELECT * FROM `pus_tpjm` WHERE ssid='$ssid'"); $k=0; //$pdf->MultiCell(100, 0, mysql_num_rows($q), 'LTRB', 'C', 0, 1, '', '', true); $kol=0; $row=0; $i=0; $nkol=floor($dcPageW/($lwidth+1)); $nrow=99; //$nrow=floor($dcPageH/$lheight); while($r=mysql_fetch_array($q)){ $t01=mysql_query("SELECT pus_buku.replid,pus_buku.idbuku,pus_buku.barkode,pus_katalog.callnumber FROM pus_buku LEFT JOIN pus_katalog ON pus_katalog.replid=pus_buku.katalog WHERE pus_buku.replid='".$r['buku']."' LIMIT 0,1"); $b=mysql_fetch_array($t01); //$b=dbSFA("*","pus_buku","W/replid='".$r['buku']."'"); // Print Label >> $x=($lwidth+1)*$kol+$dcMarginL; $y=$lheight*$row+$dcMarginT; $pdf->SetXY($x,$y); $pl=false; if($plhead=='1'){ $pl=true; $pdf->setCellPaddings(0, 0.5, 0, 0); $pdf->SetFont('dejavusans', '', 10, '', true); $pdf->MultiCell($lwidth, 0, $title, 'LTR', 'C', 0, 1, '', '', true); if($k==0) $lheight+=$pdf->getLastH(); $pdf->SetX($x); $pdf->setCellPaddings(0, 0, 0, 0.5); $pdf->SetFont('dejavusans', '', 7, '', true); $pdf->MultiCell($lwidth, 0, $desc, 'LBR', 'C', 0, 9, '', '', true); if($k==0) $lheight+=$pdf->getLastH(); } if($plcnum=='1'){ $pl=true; //dc_YDown(1); $pdf->SetX($x); $pdf->setCellPaddings(0,0.5,0,0.5); $pdf->SetFont('dejavusans', 'B', 10, '', true); $cx=str_replace(" ","\n",preg_replace("/\s+/"," ",$b['callnumber'])); $pdf->MultiCell($lwidth, 0, $cx, 1, 'C', 0, 1, '', '', true); //dc_YDown(1); if($k==0) $lheight+=$pdf->getLastH(); }
public function add_table($table) { $absolute_position = $this->is_absolute($table); if (!$absolute_position) { $this->validate_position($table->ancho); } if ($table->fondo) { $this->choose_color(); } $this->SetLineWidth(0.3); // set the width of the table $margins = parent::getMargins(); if ($table->ancho == 0) { if (parent::GetX() == $margins['left']) { $table->ancho = $this->document_width; } elseif (isset($table->x)) { $table->ancho = $this->document_width - $table->x; } else { $table->ancho = $this->document_width - $this->last_width; } } // get the widths of the headers $encabezados = (array) $table->encabezados; $string_widths = 0; $has_superheaders = false; foreach ($encabezados as $key => $cell) { if (is_array($cell)) { $has_superheaders = true; foreach ($cell as $value) { $string_widths += parent::GetStringWidth($value); } } else { $string_widths += parent::GetStringWidth($cell); } } if ($table->borde == 0) { $header_border = 'B'; $data_border = 0; } else { $header_border = 1; $data_border = 'LR'; } // print headers $x = parent::GetX(); $y = parent::GetY(); $widths = array(); $i = 0; if ($has_superheaders) { $cell_h = 26; } else { $cell_h = 13; } foreach ($encabezados as $index => $cell) { if (is_array($cell)) { $super_w = 0; $super_x = parent::GetX(); foreach ($cell as $key => $value) { array_push($widths, $this->GetStringWidth($value) / $string_widths * $table->ancho); parent::WriteHTMLCell($widths[$i + $key], $cell_h / 2, parent::GetX(), $y + $cell_h / 2, "<b>" . $value . "</b>", $header_border, 0, $table->fondo, true, 'C'); $super_w += $widths[$i + $key]; } parent::WriteHTMLCell($super_w, $cell_h / 2, $super_x, $y, "<b>" . $index . "</b>", $header_border, 0, $table->fondo, true, 'C'); parent::SetXY(parent::GetX(), $y + $cell_h / 2); } else { array_push($widths, $this->GetStringWidth($cell) / $string_widths * $table->ancho); parent::WriteHTMLCell($widths[$index], $cell_h, parent::GetX(), $y, "<b>" . $cell . "</b>", $header_border, 0, $table->fondo, true, 'C'); } $i++; } parent::Ln(); parent::SetX($x); // print data $fill = false; foreach ($table->datos as $row) { foreach ($row as $i => $field) { $this->WriteHTMLCell($widths[$i], 6, '', '', $field, $data_border, 0, $fill, true, 'L', true); } if (parent::GetY() + 20 > parent::getPageHeight() - PDF_MARGIN_BOTTOM) { parent::AddPage(); } $height = parent::getLastH(); $this->Ln(); if ($table->fondo) { $fill = !$fill; } } $this->Cell(array_sum($widths), 0, '', 'T', $table->salto); // set document positions parent::SetXY(parent::GetX() + $this->separator, parent::GetY()); if ($absolute_position) { $this->last_width = parent::GetX(); } $y = parent::GetY(); if ($y > $this->last_height) { $this->last_height = $y; } }
function create_account_pdf($name_ca, $edrpou, $type_account, $email, $tel, $session_user_uuid) { // $session_user_uuid = 'd7b6e0d4-36c2-11e5-8eee-0017315e2427'; if ($session_user_uuid == 'ef7f2df7-2b9e-11e5-b075-0017315e2427') { $header_account_name = <<<EOD Фізична особа - підприємець Чабан Олександр Сергійович EOD; $header_account_property = <<<EOD Банк Ф-Я ЮЖ. ГОЛ.РЕГ.УПР.ЗАТ КБ""ПРИВАТБАНК"", МФО 328704 р/р 26000054315095 , ЄДРПОУ 2579701431, № свід. 108703, Платник єдиного податку III група. Не є платником ПДВ. EOD; $header_account_logotext = <<<EOD www.e911.com.ua EOD; $header_main_supplier = <<<EOD ФОП Чабан Олександр Сергійович ЕДРПОУ: 2579701431 тел: (048) 794-51-37 sonata@e911.com.ua EOD; $footer_sign = <<<EOD ___________________ Чабан О.С. м.п. EOD; $footer_info = <<<EOD Увага ! При сплаті рахунку УВАЖНО вказуйте номер та дату рахунку ! Виникли питання, телефонуйте : (044)3322440 (048)7945137 (0552)440530 (0322)539770 (0629)486910 (0412)551990 (068)7756837 (066)7980357 (063)8317948 (056)7850715 (0542)705991 (0612)201340 (0462)972990 (0352)400629 Або залишайте питання на сайті e911.com.ua {$session_user_uuid} EOD; $footer_sign_stamp = 'chab.jpg'; $header_logo_png = 'logo.png'; } else { if ($session_user_uuid == 'ebff8dc0-311b-11e5-a676-0017315e2427') { $header_account_name = <<<EOD Фізична особа - підприємець Чорноус Сергій Олександрович EOD; $header_account_property = <<<EOD Банк АТ Укрсиббанк м.Херсон , МФО 351005 р/р 26009274877100, ЄДРПОУ 2925212898, Платник єдиного податку III група. Не є платником ПДВ. EOD; $header_account_logotext = <<<EOD sonata.biz.ua EOD; $header_main_supplier = <<<EOD ФОП Чорноус Сергій Олександрович ЕДРПОУ: 2925212898 тел: (0552)44-05-30 office@sonata.biz.ua EOD; $footer_sign = <<<EOD ___________________ Чорноус С.О. м.п. EOD; $footer_info = <<<EOD Увага ! При сплаті рахунку УВАЖНО вказуйте номер та дату рахунку ! Виникли питання, телефонуйте : (044)3322440 (048)7945137 (0552)440530 (0322)539770 (0629)486910 (0412)551990 (068)7756837 (066)7980357 (063)8317948 (056)7850715 (0542)705991 (0612)201340 (0462)972990 (0352)400629 Або залишайте питання на сайті sonata.biz.ua EOD; $footer_sign_stamp = 'cher.jpg'; $header_logo_png = 'header_logo_sonata.png'; } else { $header_account_name = <<<EOD Фізична особа - підприємець Чабан Олександр Сергійович EOD; $header_account_property = <<<EOD Банк Ф-Я ЮЖ. ГОЛ.РЕГ.УПР.ЗАТ КБ""ПРИВАТБАНК"", МФО 328704 р/р 26000054315095 , ЄДРПОУ 2579701431, № свід. 108703, Платник єдиного податку III група. Не є платником ПДВ. EOD; $header_account_logotext = <<<EOD www.e911.com.ua EOD; $header_main_supplier = <<<EOD ФОП Чабан Олександр Сергійович ЕДРПОУ: 2579701431 тел: (048) 794-51-37 sonata@e911.com.ua EOD; $footer_sign = <<<EOD ___________________ Чабан О.С. м.п. EOD; $footer_info = <<<EOD Увага ! При сплаті рахунку УВАЖНО вказуйте номер та дату рахунку ! Виникли питання, телефонуйте : (044)3322440 (048)7945137 (0552)440530 (0322)539770 (0629)486910 (0412)551990 (068)7756837 (066)7980357 (063)8317948 (056)7850715 (0542)705991 (0612)201340 (0462)972990 (0352)400629 Або ** залишайте питання на сайті e911.com.ua EOD; $footer_sign_stamp = 'chab.jpg'; $header_logo_png = 'logo.png'; } } $date_now = date("m.d.y"); $number_acc = date("Hms"); $type_acc = '00'; $number_acc_id = $type_acc . $number_acc; // $name_ca = 'ООО"Лютики Цветочки скорочена назва пыдприемства до 256 знакыв"'; // $edrpou = '36524587'; // $tel = ''; // $email = '*****@*****.**'; switch ($type_account) { case "s3": $namelic = 'Супроводження ПЗ Соната 3 місяці'; $sum = 250; $sum_prop = 'Двісті п\'тдесят'; break; case "s6": $namelic = 'Супроводження ПЗ Соната 6 місяців'; $sum = 360; $sum_prop = 'Триста шістдесят'; break; case "s12": $namelic = 'Супроводження ПЗ Соната 12 місяців'; $sum = 500; $sum_prop = 'П\'ятсот'; break; case "sf12": $namelic = 'Супроводження ПЗ Соната 12 місяців'; $sum = 200; $sum_prop = 'Двісті'; break; case "ecp_s2": $namelic = 'Послуга цифрового підпису за договором доручення (тариф стандартний)'; $sum = 322; $sum_prop = 'Триста двадцять дві'; break; case "ecp_s3": $namelic = 'Послуга цифрового підпису за договором доручення (тар. стандартний)'; $sum = 483; $sum_prop = 'Чотириста вісімдесят три'; break; case "ecp_l1": $namelic = 'Послуга електронного цифрового підпису за договором доручення (тариф легкий)'; $sum = 140; $sum_prop = 'Сто сорок'; break; case "ecp_l2": $namelic = 'Послуга електронного цифрового підпису за договором доручення (тариф легкий)'; $sum = 280; $sum_prop = 'Двісті вісімдесят'; break; case "w1": $namelic = 'Налаштування програмного забезпечення '; $sum = 200; $sum_prop = 'Двісті'; break; case "Kaspersky Internet Security 2016 - 2 ПК": $namelic = 'ПЗ Kaspersky Internet Security 2016 - 2 ПК 12 міс.'; $sum = 680; $sum_prop = 'Шістсот вісімдесят'; break; case "Kaspersky Internet Security 2016 - продление 1 ПК": $namelic = 'ПЗ Kaspersky Internet Security 2016 - 1 ПК продовження 12 міс.'; $sum = 380; $sum_prop = 'Триста вісімдесят'; break; case "Kaspersky Internet Security 2016 - продление 2 ПК": $namelic = 'ПЗ Kaspersky Internet Security 2016 - 2 ПК продовження 12 міс.'; $sum = 550; $sum_prop = 'П\'ятсот п\'ятдесят'; break; case "avast! Pro Antivirus 2015 - 1 ПК": $namelic = 'avast! Pro Antivirus 2015 - 1 ПК 12 міс.'; $sum = 275; $sum_prop = 'Двісті сімдесят п\'ять'; break; case "avast! Pro Antivirus 2015 - продление 1 ПК": $namelic = 'avast! Pro Antivirus 2015 - 1 ПК продовження 12 міс.'; $sum = 215; $sum_prop = 'Двісті п\'ятнадцять'; break; case "avast! Internet Security 8 - 1 ПК": $namelic = 'avast! Internet Security 8 - 1 ПК 12 міс.'; $sum = 290; $sum_prop = 'Двісті дев\'яносто'; break; case "avast! Internet Security 8 - продление 1 ПК": $namelic = 'avast! Internet Security 8 - 1 ПК продовженя 12 міс.'; $sum = 240; $sum_prop = 'Двісті сорок'; break; default: $namelic = 'Супроводження ПЗ Соната'; $sum = 500; $sum_prop = 'П\'ятсот'; break; } // $namelic = ' Прогорамма соната 12 месяцев'; // $sum = '500 '; // $sum_prop = 'пятьчот'; // define('PDF_PATH_IMAGE', '/include/image/'); define('PDF_PATH', '/include/'); //define ('FILE_PDF_PATH','include/file/'); $this->load->library('Pdf'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->AddPage(); // Основные показатели $hx = 11; // высота ячейки $Wzamov = 50; $Wisp = 120; $Wmulticel = 50; // Заголовок $pdf->Image(PDF_PATH_IMAGE . $header_logo_png, 10, 10, 65, 20, 'png', '', '', true, 300, '', false, false, false, false, false, false); $pdf->SetFont('dejavusans', 'B', 10); // Header $pdf->Write(5, $header_account_name, '', 0, 'R', true, 0, false, false, 0, 0); $pdf->SetFont('dejavusans', '', 9); // $pdf->Write(5, $header_account_property, '', 0, 'R', true, 0, false, false, 0,0,array(1,1)); $pdf->Write(0, $header_account_property, '', 0, 'R', true, 0, false, false, 0); // e911.com.ua $pdf->SetFont('dejavusans', '', 9); $pdf->Write(5, $header_account_logotext, '', 0, 'L', true, 0, false, false, 0, 0, array(1, 1)); $pdf->SetFont('dejavusans', '', 8); $date = Date("d.m.Y"); $pdf->SetFillColor(255, 255, 255); // $ypost = 54; $pdf->SetFont('', 'B', 9); $y_header = 40; $pdf->SetY($y_header, true); $pdf->cell(50, $hx, 'Постачальник:', 0, 'L'); $pdf->SetY($y_header, true); $pdf->SetX(100, true); $pdf->cell(50, $hx, 'Платник:', 0, 'L'); $wedhtCell = 50; $pdf->SetFont('', '', 9); // header_main_supplier $pdf->SetY(50, true); $pdf->SetX(10, true); // $pdf->SetY($ypost+8,true); $pdf->multicell(100, $hx, $header_main_supplier, 0, 'L', 1, 0, '', '', true); $txt = <<<EOD {$name_ca} ЕДРПОУ: {$edrpou} тел: {$tel} {$email} EOD; $pdf->SetY(50, true); $pdf->SetX(100, true); $pdf->multicell(100, $hx, $txt, 0, 'L', 1, 0, '', '', true); // ЗАКАЗ $pdf->SetFont('dejavusans', 'B', 16); // set some text to print $number_acc_id = $type_acc . $number_acc; $txt = <<<EOD Рахунок № {$number_acc_id} від {$date} EOD; $pdf->SetY(80, true); $pdf->Write(5, $txt, '', 0, 'C', true, 0, false, false, 0, 0); $pdf->SetFont('dejavusans', '', 8); $txt = <<<EOD за інформаційні послуги EOD; $pdf->Write(5, $txt, '', 0, 'C', true, 0, false, false, 0, 0); // Table Account $x = 10; // Start Horizont $xf = 190; // Finish horizont $y = 100; // start vertical $wx = 72; $wmin = $wx - 36; $pdf->SetFont('', '', 11); // Header table $pdf->SetFont('', 'B', 11); $pdf->SetY($y - 10, true); $pdf->cell($wx, $hx, 'Найменування', 'B', 0, 'L'); $pdf->cell($wmin, $hx, 'Кількість', 'B', 0, 'R'); $pdf->cell($wmin, $hx, 'Ціна,грн', 'B', 0, 'R'); $pdf->cell($wmin, $hx, 'Сума,грн', 'B', 0, 'R'); // Date Table $tableHeight = 6; $pdf->SetFont('', '', 9); $pdf->SetY($y + 1, true); // $pdf->cell($wx,$tableHeight,$namelic,'B',0,'L'); // $pdf->cell($wmin,$tableHeight,1,'B',0,'C'); // $pdf->cell($wmin,$tableHeight,$sum,'B',0,'C'); // $pdf->cell($wmin,$tableHeight,$sum,'B',0,'C'); $html = ' <table border="1" cellspacing="0" cellpadding="2"> <tr> <td align="left" width="250">' . $namelic . '</td> <td align="center" width="90">1</td> <td align="center" width="90">' . $sum . '</td> <td align="center" width="90">' . $sum . '</td> </tr> </table> '; $pdf->writeHTML($html, true, false, true, false, ''); // Footer table $pdf->SetFont('', 'B', 11); $pdf->SetY($y + 15, true); $pdf->cell($wx, $hx, 'Разом: ' . $sum_prop . ' гривень 00 коп. без ПДВ', '', 0, 'L'); $pdf->SetFillColor(255, 255, 255); $pdf->Image(PDF_PATH_IMAGE . $footer_sign_stamp, 40, 125, 40, 40, 'jpg', '', '', true, 1000, '', false, false, false, false, false, false); $ypost = 140; $pdf->SetFont('', 'B', 9); $pdf->SetY($ypost, true); $pdf->cell($Wisp, $hx, 'Постачальник:', 0, 'L'); // $pdf->cell($Wzamov,$hx,'Від замовника:',0,'L'); $pdf->SetFont('', '', 9); // $txt = <<<EOD // ___________________ Чабан О.С. // м.п. // EOD; $pdf->SetY($ypost, true); $pdf->SetX(50, true); $pdf->multicell($Wmulticel + 10, $hx, $footer_sign, 0, 'L', 1, 0, '', '', true); $pdf->SetFont('dejavusans', '', 8); $pdf->SetY(150, true); $pdf->Write(5, $footer_info, '', 0, 'L', true, 0, false, false, 0, 0); $pdf->Output(FCPATH . '/include/file/sonata_rahunok.pdf', 'F'); // OUTPUT THE NEW PDF INTO THE SAME DIRECTORY DEFINED ABOVE }
// Summarize $btot = mysql_num_rows(mysql_query("SELECT * FROM `book`")); $bdue = mysql_num_rows(mysql_query("SELECT * FROM `" . $r['ntable'] . "`")); //$bcek=mysql_num_rows(mysql_query("SELECT * FROM `".$r['ntable']."cek`")); $bcekY = mysql_num_rows(mysql_query("SELECT * FROM `" . $r['ntable'] . "` WHERE cek='Y'")); $bcekN = $bdue - $bcekY; //mysql_num_rows(mysql_query("SELECT * FROM `".$r['ntable']."` WHERE cek='N'")); $bcek = $bcekY + $bcekN; $bcekYp = round($bcekY * 100 / $bcek, 2); $bcekNp = round($bcekN * 100 / $bcek, 2); $buli = mysql_num_rows(mysql_query("SELECT * FROM `" . $r['ntable'] . "new`")); $pdf->SetFont('dejavusans', '', 8, '', true); $pdf->MultiCell(30, 0, 'Stock take name', 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(100, 0, ': ' . $r['name'], 0, 'L', 0, 0, '', '', true); if ($psum == '1') { $pdf->SetX($dcPaperW - 85); $pdf->MultiCell(30, 0, 'Total book in list', 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(100, 0, ': ' . $btot . ' book' . ($btot > 1 ? 's' : ''), 0, 'L', 0, 1, '', '', true); } else { $pdf->Ln(); } $pdf->MultiCell(30, 0, 'Stock take date', 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(100, 0, ': ' . fftgl($r['date']), 0, 'L', 0, 0, '', '', true); if ($psum == '1') { $pdf->SetX($dcPaperW - 85); $pdf->MultiCell(30, 0, 'Total book checked', 0, 'L', 0, 0, '', '', true); $pdf->MultiCell(100, 0, ': ' . $bcekY . " ( " . $bcekYp . " % )" . " book" . ($bcekY > 1 ? "s" : ""), 0, 'L', 0, 1, '', '', true); } else { $pdf->Ln(); } $pdf->MultiCell(30, 0, 'Finished', 0, 'L', 0, 0, '', '', true);
$pdf->SetXY(67,9+$numefftot*$passo); $pdf->SetFont('times','',14); $pdf->Cell(60,10,$admin_aziend['citspe'].', '.$datafatt); $pdf->SetXY(165,12+$numefftot*$passo); $pdf->Cell(67,10,gaz_format_number($effetto['impeff'])); $pdf->SetXY(85,21+$numefftot*$passo); $pdf->Cell(50,10,$scadenza); $pdf->SetXY(76,34+$numefftot*$passo); $pdf->Cell(120,10,$admin_aziend['ragso1'].' '.$admin_aziend['ragso2']); $pdf->SetXY(90,45+$numefftot*$passo); $pdf->Cell(140,10,substr($impwords,4,99)); $pdf->SetXY(5,60+$numefftot*$passo); $pdf->SetFont('helvetica','B',7); $pdf->Cell(71,6,substr($banapp['descri'],0,34)); $pdf->Cell(80,6,$client['ragso1'].' '.$client['ragso2'],0,1,'L'); $pdf->SetX(5); $pdf->Cell(71,6,'ABI: '.$banapp['codabi']); $pdf->Cell(80,6,$client['codfis'],0,1,'L'); $pdf->SetX(5); $pdf->Cell(71,6,'CAB: '.$banapp['codcab']); $pdf->Cell(80,6,$client['indspe'],0,1,'L'); $pdf->SetX(5); $pdf->Cell(71,6,$banapp['locali'].' ('.$banapp['codpro'].')'); $pdf->Cell(80,6,$client['capspe'].' '.$client['citspe'].' ('.$client['prospe'].')',0,1,'L'); $pdf->SetXY(5,90+$numefftot*$passo); $pdf->Cell(165,4,'Cambiale-tratta n.'.$effetto['progre'].' emessa '.$salcon.$effetto['numfat'].'/'.$effetto['seziva'].' del '.$datafatt.' di € '.$effetto['totfat'],'LTB'); $pdf->Cell(37,4,'bolli a tergo € '.gaz_format_number($impbol),'RTB',1,'R'); break; //questo è il modulo delle cambiali tratte case "V": $calc->payment_taxstamp($effetto['impeff'],$admin_aziend['perbol']);
public function generateJobOrderReportPDF() { /* E_STRICT doesn't like FPDF. */ $errorReporting = error_reporting(); error_reporting($errorReporting & ~ E_STRICT); include_once('./lib/fpdf/fpdf.php'); error_reporting($errorReporting); // FIXME: Hook? $isASP = $_SESSION['CATS']->isASP(); $unixName = $_SESSION['CATS']->getUnixName(); $siteName = $this->getTrimmedInput('siteName', $_GET); $companyName = $this->getTrimmedInput('companyName', $_GET); $jobOrderName = $this->getTrimmedInput('jobOrderName', $_GET); $periodLine = $this->getTrimmedInput('periodLine', $_GET); $accountManager = $this->getTrimmedInput('accountManager', $_GET); $recruiter = $this->getTrimmedInput('recruiter', $_GET); $notes = $this->getTrimmedInput('notes', $_GET); if (isset($_GET['dataSet'])) { $dataSet = $_GET['dataSet']; $dataSet = explode(',', $dataSet); } else { $dataSet = array(4, 3, 2, 1); } /* PDF Font Face. */ // FIXME: Customizable. $fontFace = 'helvetica'; $pdf=new \TCPDF(); //$pdf = new FPDF(); $pdf->AddPage(); if (!eval(Hooks::get('REPORTS_CUSTOMIZE_JO_REPORT_PRE'))) return; $pdf->SetFont($fontFace, 'B', 10); if ($isASP && $unixName == 'cognizo') { /* TODO: MAKE THIS CUSTOMIZABLE FOR EVERYONE. */ $pdf->Image('images/cognizo-logo.jpg', 130, 10, 59, 20); $pdf->SetXY(129,27); $pdf->Write(5, 'Information Technology Consulting'); } $pdf->SetXY(25, 35); $pdf->SetFont($fontFace, 'BU', 14); $pdf->Write(5, "Recruiting Summary Report\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, DateUtility::getAdjustedDate('l, F d, Y') . "\n\n\n"); $pdf->SetFont($fontFace, 'B', 10); $pdf->SetX(25); $pdf->Write(5, 'Company: '. $companyName . "\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Position: ' . $jobOrderName . "\n\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Period: ' . $periodLine . "\n\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Account Manager: ' . $accountManager . "\n"); $pdf->SetFont($fontFace, '', 10); $pdf->SetX(25); $pdf->Write(5, 'Recruiter: ' . $recruiter . "\n"); /* Note that the server is not logged in when getting this file from * itself. */ // FIXME: Pass session cookie in URL? Use cURL and send a cookie? I // really don't like this... There has to be a way. // FIXME: "could not make seekable" - http://demo.catsone.net/index.php?m=graphs&a=jobOrderReportGraph&data=%2C%2C%2C // in /usr/local/www/catsone.net/data/lib/fpdf/fpdf.php on line 1500 $URI = CATSUtility::getAbsoluteURI( CATSUtility::getIndexName() . '?m=graphs&a=jobOrderReportGraph&data=' . urlencode(implode(',', $dataSet)) ); $pdf->Image($URI, 70, 95, 80, 80, 'jpg'); $pdf->SetXY(25,180); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(255, 0, 0); $pdf->Write(5, 'Screened'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' by ' . $siteName . ": \n\n"); $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(0, 125, 0); $pdf->Write(5, 'Submitted'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' to ' . $companyName . ": \n\n"); $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(0, 0, 255); $pdf->Write(5, 'Interviewed'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' by ' . $companyName . ": \n\n"); $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, 'Total Candidates '); $pdf->SetTextColor(255, 75, 0); $pdf->Write(5, 'Placed'); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, ' at ' . $companyName . ": \n\n\n"); if ($notes != '') { $pdf->SetX(25); $pdf->SetFont($fontFace, '', 10); $pdf->Write(5, "Notes:\n"); $len = strlen($notes); $maxChars = 70; $pdf->SetLeftMargin(25); $pdf->SetRightMargin(25); $pdf->SetX(25); $pdf->Write(5, $notes . "\n"); } $pdf->SetXY(165, 180); $pdf->SetFont($fontFace, 'B', 10); $pdf->Write(5, $dataSet[0] . "\n\n"); $pdf->SetX(165); $pdf->Write(5, $dataSet[1] . "\n\n"); $pdf->SetX(165); $pdf->Write(5, $dataSet[2] . "\n\n"); $pdf->SetX(165); $pdf->Write(5, $dataSet[3] . "\n\n"); $pdf->Rect(3, 6, 204, 285); if (!eval(Hooks::get('REPORTS_CUSTOMIZE_JO_REPORT_POST'))) return; $pdf->Output(); die(); }
public function salary_sso_pdf_export() { $m = Input::get('m_sso_1'); $y = Input::get('y_sso_1'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetPrintHeader(false); // set header and footer fonts $pdf->setHeaderFont(array('freeserif', 'B', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array('freeserif', 'B', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(10, 15, 10); $pdf->SetHeaderMargin(15); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetFont('freeserif', '', 14, '', true); $n = DB::select('select * from s_general_data'); foreach ($n as $k) { $name = $k->name; } $sql = ' select s.cid, concat(n.pname,"",n.fname," ",n.lname) as name, (s.salary+s.salary_other) as salary, s.salary_sso '; $sql .= ' from s_salary_detail s'; $sql .= ' left join n_datageneral n on n.cid=s.cid'; $sql .= ' where year(order_date)=' . $y . ' and month(order_date)=' . $m . ' '; $data = DB::Select($sql); $j = 0; $row = 0; $sum1 = 0; $sum2 = 0; foreach ($data as $k) { $row++; if ($j == 30) { $j = 0; } if ($j == 0) { $pdf->AddPage('', 'A4'); //header $pdf->SetFont('freeserif', '', 12, '', true); $pdf->SetY(5); $pdf->SetX(160); $pdf->MultiCell(40, 5, 'สปส.1-10 (ส่วนที่ 2)', 0, 'R', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 14, '', true); $pdf->MultiCell(190, 5, 'แบบรายงานการแสดงการส่งเงินสมทบ ', 0, 'C', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(18); $pdf->MultiCell(190, 5, 'การนำส่งเงินสมทบสำหรับค่าจ้างเดิอน ' . $this->get_monthyearThai($m, $y), 0, 'C', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(30); $pdf->SetX(10); $pdf->MultiCell(40, 5, 'ชื่อสถานประกอบการ ', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(30); $pdf->SetX(50); $pdf->MultiCell(70, 5, $name, 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(30); $pdf->SetX(140); $pdf->MultiCell(22, 5, 'เลขที่บัญชี', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(30); $pdf->SetX(163); $pdf->MultiCell(25, 5, '1090000219', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(36); $pdf->SetX(140); $pdf->MultiCell(22, 5, 'สาขา', 0, 'L', 0, 1, '', '', true); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(36); $pdf->SetX(163); $pdf->MultiCell(25, 5, '300311', 0, 'L', 0, 1, '', '', true); $linever = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0)); $pdf->Line(200, 43, 10, 43, $linever); $pdf->Line(200, 50, 10, 50, $linever); $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(43); $pdf->SetX(10); $pdf->MultiCell(20, 7, 'ลำดับที่', 0, 'C', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(30); $pdf->MultiCell(40, 7, 'เลขประจำตัวประชาชน', 0, 'C', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(70); $pdf->MultiCell(70, 7, 'ชื่อ-สกุล', 0, 'C', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(140); $pdf->MultiCell(30, 7, 'ค่าจ้าง', 0, 'R', 0, 1, '', '', true); $pdf->SetY(43); $pdf->SetX(170); $pdf->MultiCell(30, 7, 'เงินสมทบ', 0, 'R', 0, 1, '', '', true); } //end add header //detail $pdf->SetY(50 + $j * 7.5); $pdf->SetX(10); $pdf->MultiCell(20, 7, $row, 0, 'R', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(30); $pdf->MultiCell(40, 7, $k->cid, 0, 'C', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(70, 7, $k->name, 0, 'L', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(140); $pdf->MultiCell(30, 7, number_format($k->salary, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(170); $pdf->MultiCell(30, 7, number_format($k->salary_sso, 2), 0, 'R', 0, 1, '', '', true); //end detail $sum1 = $sum1 + $k->salary; $sum2 = $sum2 + $k->salary_sso; $j++; } // end data //sum all $pdf->Line(200, 50 + $j * 7.5, 10, 50 + $j * 7.5, $linever); $pdf->Line(200, 56 + $j * 7.5, 10, 57 + $j * 7.5, $linever); $pdf->SetFont('freeserif', 'B', 13, '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(70, 7, 'ยอดรวม', 0, 'C', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(140); $pdf->MultiCell(30, 7, number_format($sum1, 2), 0, 'R', 0, 1, '', '', true); $pdf->SetY(50 + $j * 7.5); $pdf->SetX(170); $pdf->MultiCell(30, 7, number_format($sum2, 2), 0, 'R', 0, 1, '', '', true); //end sum all // $pdf->SetFont('freeserif', '', 13, '', true); $pdf->SetY(62 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(90, 5, 'ลงชื่อ.............................................................', 0, 'R', 0, 1, '', '', true); $pdf->SetY(62 + $j * 7.5); $pdf->SetX(160); $pdf->MultiCell(43, 5, 'นายจ้าง/ผู้รับมอบอำนาจ', 0, 'R', 0, 1, '', '', true); $pdf->SetY(70 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(90, 5, '(.............................................................)', 0, 'R', 0, 1, '', '', true); $pdf->SetY(82 + $j * 7.5); $pdf->SetX(70); $pdf->MultiCell(120, 5, 'ยื่นแบบวันที่.............เดือน..............................พ.ศ..............', 0, 'C', 0, 1, '', '', true); $filename = storage_path() . '/salary_sso_pdf_export.pdf'; // Response::download($filename); $contents = $pdf->output($filename, 'I'); $headers = array('Content-Type' => 'application/pdf'); return Response::make($contents, 200, $headers); }
while ($r = mysql_fetch_array($q)) { $b = dbSFA("*", "book", "W/dcid='" . $r['book'] . "'"); // Print Label >> $x = ($lwidth + 1) * $kol + $dcMarginL; $y = $lheight * $row + $dcMarginT; $pdf->SetXY($x, $y); $pl = false; if ($plhead == 'Y') { $pl = true; $pdf->setCellPaddings(0, 0.5, 0, 0); $pdf->SetFont('dejavusans', '', 10, '', true); $pdf->MultiCell($lwidth, 0, $title, 'LTR', 'C', 0, 1, '', '', true); if ($k == 0) { $lheight += $pdf->getLastH(); } $pdf->SetX($x); $pdf->setCellPaddings(0, 0, 0, 0.5); $pdf->SetFont('dejavusans', '', 7, '', true); $pdf->MultiCell($lwidth, 0, $desc, 'LBR', 'C', 0, 9, '', '', true); if ($k == 0) { $lheight += $pdf->getLastH(); } } if ($plcnum == 'Y') { $pl = true; //dc_YDown(1); $pdf->SetX($x); $pdf->setCellPaddings(0, 0.5, 0, 0.5); $pdf->SetFont('dejavusans', 'B', 10, '', true); $cx = str_replace(" ", "\n", $b['callnumber']); $pdf->MultiCell($lwidth, 0, $cx, 1, 'C', 0, 1, '', '', true);
/** * Generate PDF for Voucher * * Handles to Generate PDF on run time when * user will execute the url which is sent to * user email with purchase receipt * * @package WooCommerce - PDF Vouchers * @since 1.0.0 */ function woo_vou_generate_voucher_code_pdf() { $prefix = WOO_VOU_META_PREFIX; // Getting voucher character support $voucher_char_support = get_option('vou_char_support'); // Taking pdf fonts $pdf_font = 'helvetica'; // This is default font if (!empty($pdf_args['char_support'])) { // if character support is checked //If character support is enable then assing default character to freesarif $pdf_font = 'freeserif'; if (defined('WOO_VOU_PF_DIR')) { // if pdf font plugin is active //Get pdf font from font plugin of pdf voucher $vou_pdf_font = get_option('vou_pdf_font'); if (!empty($vou_pdf_font)) { $pdf_font = $vou_pdf_font; } } } if (isset($_GET['woo-vou-used-gen-pdf']) && !empty($_GET['woo-vou-used-gen-pdf']) && $_GET['woo-vou-used-gen-pdf'] == '1' && isset($_GET['product_id']) && !empty($_GET['product_id'])) { global $current_user, $woo_vou_model, $post; //Create html for PDF $html = ''; //model class $model = $woo_vou_model; $postid = $_GET['product_id']; if (!class_exists('TCPDF')) { //If class not exist //include tcpdf file require_once WOO_VOU_DIR . '/includes/tcpdf/tcpdf.php'; } // Check action is used codes if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { //Get Voucher Details by post id $voucodes = $model->woo_vou_get_used_codes_by_product_id($postid); $voucher_heading = __('Used Voucher Codes', 'woovoucher'); $voucher_empty_msg = __('No voucher codes used yet.', 'woovoucher'); $vou_file_name = 'woo-used-voucher-codes-{current_date}'; } else { //Get Voucher Details by post id $voucodes = $model->woo_vou_get_purchased_codes_by_product_id($postid); $voucher_heading = __('Purchased Voucher Codes', 'woovoucher'); $voucher_empty_msg = __('No voucher codes purchased yet.', 'woovoucher'); $vou_pdf_name = get_option('vou_pdf_name'); $vou_file_name = !empty($vou_pdf_name) ? $vou_pdf_name : 'woo-purchased-voucher-codes-{current_date}'; } $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // remove default header $pdf->setPrintHeader(false); // remove default footer $pdf->setPrintFooter(false); $pdf->AddPage('L', 'A4'); // Auther name and Creater name $pdf->SetTitle(utf8_decode(__('WooCommerce Voucher', 'woovoucher'))); $pdf->SetAuthor(utf8_decode(__('WooCommerce', 'woovoucher'))); $pdf->SetCreator(utf8_decode(__('WooCommerce', 'woovoucher'))); // Set margine of pdf (float left, float top , float right) $pdf->SetMargins(8, 8, 8); $pdf->SetX(8); // Font size set $pdf->SetFont($pdf_font, '', 18); $pdf->SetTextColor(50, 50, 50); $pdf->Cell(270, 5, utf8_decode($voucher_heading), 0, 2, 'C', false); $pdf->Ln(5); $pdf->SetFont($pdf_font, '', 12); $pdf->SetFillColor(238, 238, 238); //voucher logo if (!empty($voulogo)) { $pdf->Image($voulogo, 95, 25, 20, 20); $pdf->Ln(35); } $columns = array(array('name' => __('Voucher Code', 'woovoucher'), 'width' => 70), array('name' => __('Buyer\'s Name', 'woovoucher'), 'width' => 70), array('name' => __('Order Date', 'woovoucher'), 'width' => 50)); if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { // if generate pdf for used code add and extra column $new_columns[] = array('name' => __('Order ID', 'woovoucher'), 'width' => 35); $new_columns[] = array('name' => __('Redeem By', 'woovoucher'), 'width' => 50); $columns = array_merge($columns, $new_columns); } else { $new_columns[] = array('name' => __('Order ID', 'woovoucher'), 'width' => 70); $columns = array_merge($columns, $new_columns); } $html .= '<table style="line-height:1.5;" border="1"><thead><tr style="line-height:2;font-weight:bold;background-color:#EEEEEE;">'; // Table head Code foreach ($columns as $column) { $html .= '<th>' . $column['name'] . '</th>'; } $html .= '</tr></thead>'; $html .= '<tbody>'; if (!empty($voucodes) && count($voucodes) > 0) { foreach ($voucodes as $key => $voucodes_data) { $html .= '<tr>'; //voucher order id $orderid = $voucodes_data['order_id']; //voucher order date $orderdate = $voucodes_data['order_date']; $orderdate = !empty($orderdate) ? $model->woo_vou_get_date_format($orderdate) : ''; //buyer's name who has purchased/used voucher code $buyername = $voucodes_data['buyer_name']; //voucher code purchased/used $voucode = $voucodes_data['vou_codes']; $html .= '<td>' . $voucode . '</td>'; $html .= '<td>' . $buyername . '</td>'; $html .= '<td>' . $orderdate . '</td>'; if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { // if generate pdf for used code add and extra column $user_id = $voucodes_data['redeem_by']; $user_detail = get_userdata($user_id); $redeem_by = isset($user_detail->display_name) ? $user_detail->display_name : 'N/A'; $html .= '<td>' . $orderid . '</td>'; $html .= '<td>' . $redeem_by . '</td>'; } else { $html .= '<td>' . $orderid . '</td>'; } $html .= '</tr>'; } } else { if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { // if generate pdf for used code add and extra column $colspan = 5; } else { $colspan = 4; } $title = $voucher_empty_msg; $html .= '<tr><td colspan="' . $colspan . '">' . $title . '</td></tr>'; } $html .= '</tbody>'; $html .= '</table>'; // output the HTML content $pdf->writeHTML($html, true, 0, true, 0); // reset pointer to the last page $pdf->lastPage(); //voucher code $pdf->SetFont($pdf_font, 'B', 14); $vou_file_name = str_replace('{current_date}', date('d-m-Y'), $vou_file_name); $pdf->Output($vou_file_name . '.pdf', 'D'); exit; } // generate pdf for voucher code if (isset($_GET['woo-vou-voucher-gen-pdf']) && !empty($_GET['woo-vou-voucher-gen-pdf']) && $_GET['woo-vou-voucher-gen-pdf'] == '1') { $prefix = WOO_VOU_META_PREFIX; global $current_user, $woo_vou_model, $post, $woo_vou_vendor_role; //model class $model = $woo_vou_model; // include tcpdf library require_once WOO_VOU_DIR . '/includes/tcpdf/tcpdf.php'; // Check action is used codes if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { $args = array(); $args['meta_query'] = array(array('key' => $prefix . 'used_codes', 'value' => '', 'compare' => '!=')); //Get user role $user_roles = isset($current_user->roles) ? $current_user->roles : array(); $user_role = array_shift($user_roles); if (in_array($user_role, $woo_vou_vendor_role)) { // Check vendor user role $args['author'] = $current_user->ID; } if (isset($_GET['woo_vou_post_id']) && !empty($_GET['woo_vou_post_id'])) { $args['post_parent'] = $_GET['woo_vou_post_id']; } if (isset($_GET['s']) && !empty($_GET['s'])) { //$args['s'] = $_GET['s']; $args['meta_query'] = array('relation' => 'OR', array('key' => $prefix . 'used_codes', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'first_name', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'last_name', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'order_id', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'order_date', 'value' => $_GET['s'], 'compare' => 'LIKE')); } //Get Voucher Details by post id $voucodes = $model->woo_vou_get_voucher_details($args); $voucher_heading = __('Used Voucher Codes', 'woovoucher'); $voucher_empty_msg = __('No voucher codes used yet.', 'woovoucher'); $vou_file_name = 'woo-used-voucher-codes-{current_date}'; } else { $args = array(); if (isset($_GET['vou-data']) && $_GET['vou-data'] == 'expire') { $args['meta_query'] = array(array('key' => $prefix . 'purchased_codes', 'value' => '', 'compare' => '!='), array('key' => $prefix . 'used_codes', 'compare' => 'NOT EXISTS'), array('key' => $prefix . 'exp_date', 'compare' => '<=', 'value' => $model->woo_vou_current_date()), array('key' => $prefix . 'exp_date', 'value' => '', 'compare' => '!=')); } else { $args['meta_query'] = array(array('key' => $prefix . 'purchased_codes', 'value' => '', 'compare' => '!='), array('key' => $prefix . 'used_codes', 'compare' => 'NOT EXISTS'), array('relation' => 'OR', array('key' => $prefix . 'exp_date', 'value' => '', 'compare' => '='), array('key' => $prefix . 'exp_date', 'compare' => '>=', 'value' => $model->woo_vou_current_date()))); } //Get user role $user_roles = isset($current_user->roles) ? $current_user->roles : array(); $user_role = array_shift($user_roles); if (in_array($user_role, $woo_vou_vendor_role)) { // Check vendor user role $redeem_all = $model->woo_vou_vendor_redeem_all_codes($current_user); if (!$redeem_all) { $args['author'] = $current_user->ID; } } if (isset($_GET['woo_vou_post_id']) && !empty($_GET['woo_vou_post_id'])) { $args['post_parent'] = $_GET['woo_vou_post_id']; } if (isset($_GET['s']) && !empty($_GET['s'])) { $args['meta_query'] = array('relation' => 'OR', array('key' => $prefix . 'purchased_codes', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'first_name', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'last_name', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'order_id', 'value' => $_GET['s'], 'compare' => 'LIKE'), array('key' => $prefix . 'order_date', 'value' => $_GET['s'], 'compare' => 'LIKE')); } //Get Voucher Details by post id $voucodes = $model->woo_vou_get_voucher_details($args); $voucher_heading = __('Purchased Voucher Codes', 'woovoucher'); $voucher_empty_msg = __('No voucher codes purchased yet.', 'woovoucher'); $vou_pdf_name = get_option('vou_pdf_name'); $vou_file_name = !empty($vou_pdf_name) ? $vou_pdf_name : 'woo-purchased-voucher-codes-{current_date}'; } $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // remove default header $pdf->setPrintHeader(false); // remove default footer $pdf->setPrintFooter(false); $pdf->AddPage('L', 'A4'); // Auther name and Creater name $pdf->SetTitle(utf8_decode(__('WooCommerce Voucher', 'woovoucher'))); $pdf->SetAuthor(utf8_decode(__('WooCommerce', 'woovoucher'))); $pdf->SetCreator(utf8_decode(__('WooCommerce', 'woovoucher'))); // Set margine of pdf (float left, float top , float right) $pdf->SetMargins(8, 8, 8); $pdf->SetX(8); // Font size set $pdf->SetFont($pdf_font, '', 18); $pdf->SetTextColor(50, 50, 50); $pdf->Ln(3); $pdf->Cell(270, 5, utf8_decode($voucher_heading), 0, 2, 'C', false); $pdf->Ln(5); $pdf->SetFont($pdf_font, '', 10); $pdf->SetFillColor(238, 238, 238); //voucher logo if (!empty($voulogo)) { $pdf->Image($voulogo, 95, 25, 20, 20); $pdf->Ln(35); } if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { // if generate pdf for used code add and extra column $columns = array('vou_code' => array('name' => __('Voucher Code', 'woovoucher'), 'width' => 12), 'product_info' => array('name' => __('Product Information', 'woovoucher'), 'width' => 24), 'buyer_info' => array('name' => __('Buyer\'s Information', 'woovoucher'), 'width' => 28), 'order_info' => array('name' => __('Order Information', 'woovoucher'), 'width' => 26), 'redeem_by' => array('name' => __('Redeem By', 'woovoucher'), 'width' => 10)); } else { $columns = array('vou_code' => array('name' => __('Voucher Code', 'woovoucher'), 'width' => 20), 'product_info' => array('name' => __('Product Information', 'woovoucher'), 'width' => 25), 'buyer_info' => array('name' => __('Buyer\'s Information', 'woovoucher'), 'width' => 30), 'order_info' => array('name' => __('Order Information', 'woovoucher'), 'width' => 25)); } $pdf_type = isset($_GET['woo_vou_action']) ? $_GET['woo_vou_action'] : 'purchased'; $columns = apply_filters('woo_vou_generate_pdf_columns', $columns, $pdf_type); $html = ''; $html .= '<table style="line-height:1.5;" border="1"><thead><tr style="line-height:2;font-weight:bold;background-color:#EEEEEE;">'; // Table head Code foreach ($columns as $column) { $html .= '<th width="' . $column['width'] . '%" style="margin:10px;"> ' . $column['name'] . ' </th>'; } $html .= '</tr></thead>'; $html .= '<tbody>'; if (count($voucodes) > 0) { foreach ($voucodes as $key => $voucodes_data) { $html .= '<tr>'; //voucher order id $orderid = get_post_meta($voucodes_data['ID'], $prefix . 'order_id', true); //voucher order date $orderdate = get_post_meta($voucodes_data['ID'], $prefix . 'order_date', true); $orderdate = !empty($orderdate) ? $model->woo_vou_get_date_format($orderdate) : ''; // get order detail $order = new WC_Order($orderid); $buyer_details = $model->woo_vou_get_buyer_information($orderid); $buyerinfo = $model->woo_vou_display_buyer_info_html($buyer_details); //voucher code purchased/used $voucode = get_post_meta($voucodes_data['ID'], $prefix . 'purchased_codes', true); $user_id = get_post_meta($voucodes_data['ID'], $prefix . 'redeem_by', true); $user_detail = get_userdata($user_id); $redeem_by = isset($user_detail->display_name) ? $user_detail->display_name : 'N/A'; $product_desc = $model->woo_vou_display_product_info_html($orderid, $voucode, 'pdf'); $order_desc = $model->woo_vou_display_order_info_html($orderid, 'pdf'); $html .= '<td width="' . $columns['vou_code']['width'] . '%"> ' . $voucode . ' </td>'; $html .= '<td width="' . $columns['product_info']['width'] . '%"> ' . $product_desc . ' </td>'; $html .= '<td width="' . $columns['buyer_info']['width'] . '%">' . $buyerinfo . ' </td>'; $html .= '<td width="' . $columns['order_info']['width'] . '%"> ' . $order_desc . ' </td>'; if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { // if generate pdf for used code add and extra column $html .= '<td width="' . $columns['redeem_by']['width'] . '%"> ' . $redeem_by . ' </td>'; } ob_start(); do_action('woo_vou_generate_pdf_add_column_after', $orderid, $voucode); $added_column = ob_get_clean(); $html .= $added_column; $html .= '</tr>'; } } else { if (isset($_GET['woo_vou_action']) && $_GET['woo_vou_action'] == 'used') { // if generate pdf for used code add and extra column $colspan = 6; } else { $colspan = 5; } $title = $voucher_empty_msg; $html .= '<tr><td colspan="' . $colspan . '"> ' . $title . ' </td></tr>'; } $html .= '</tbody>'; $html .= '</table>'; // output the HTML content $pdf->writeHTML($html, true, 0, true, 0); // reset pointer to the last page $pdf->lastPage(); //voucher code $pdf->SetFont($pdf_font, 'B', 10); $vou_file_name = str_replace('{current_date}', date('d-m-Y'), $vou_file_name); $pdf->Output($vou_file_name . '.pdf', 'D'); exit; } }
/** * Renders (in PDF) the key (legend) of the graphics vertically to the left of the specified zone (xmin,ymin, xmax,ymax), * and the comment (if any) at the bottom of the page. Returns the position of remaining area. * @param TCPDF $oPdf * @param string $sComments * @param float $xMin * @param float $yMin * @param float $xMax * @param float $yMax * @param hash $aContextDefs * @return hash An array ('xmin' => , 'xmax' => ,'ymin' => , 'ymax' => ) of the remaining available area to paint the graph */ protected function RenderKey(TCPDF $oPdf, $sComments, $xMin, $yMin, $xMax, $yMax, $aContextDefs) { $fFontSize = 7; // in mm $fIconSize = 6; // in mm $fPadding = 1; // in mm $oIterator = new RelationTypeIterator($this, 'Node'); $fMaxWidth = max($oPdf->GetStringWidth(Dict::S('UI:Relation:Key')) - $fIconSize, $oPdf->GetStringWidth(Dict::S('UI:Relation:Comments')) - $fIconSize); $aClasses = array(); $aIcons = array(); $aContexts = array(); $aContextIcons = array(); $oPdf->SetFont('dejavusans', '', $fFontSize, '', true); foreach ($oIterator as $sId => $oNode) { if ($sClass = $oNode->GetObjectClass()) { if (!array_key_exists($sClass, $aClasses)) { $sClassLabel = MetaModel::GetName($sClass); $width = $oPdf->GetStringWidth($sClassLabel); $fMaxWidth = max($width, $fMaxWidth); $aClasses[$sClass] = $sClassLabel; $sIconUrl = $oNode->GetProperty('icon_url'); $sIconPath = str_replace(utils::GetAbsoluteUrlModulesRoot(), APPROOT . 'env-' . utils::GetCurrentEnvironment() . '/', $sIconUrl); $aIcons[$sClass] = $sIconPath; } } $aContextRootCauses = $oNode->GetProperty('context_root_causes'); if (!is_null($aContextRootCauses)) { foreach ($aContextRootCauses as $key => $aObjects) { $aContexts[$key] = Dict::S($aContextDefs[$key]['dict']); $aContextIcons[$key] = APPROOT . 'env-' . utils::GetCurrentEnvironment() . '/' . $aContextDefs[$key]['icon']; } } } $oPdf->SetXY($xMin + $fPadding, $yMin + $fPadding); $yPos = $yMin + $fPadding; $oPdf->SetFillColor(225, 225, 225); $oPdf->Cell($fIconSize + $fPadding + $fMaxWidth, $fIconSize + $fPadding, Dict::S('UI:Relation:Key'), 0, 1, 'C', true); $yPos += $fIconSize + 2 * $fPadding; foreach ($aClasses as $sClass => $sLabel) { $oPdf->SetX($xMin + $fIconSize + $fPadding); $oPdf->Cell(0, $fIconSize + 2 * $fPadding, $sLabel, 0, 1); $oPdf->Image($aIcons[$sClass], $xMin + 1, $yPos, $fIconSize, $fIconSize); $yPos += $fIconSize + 2 * $fPadding; } foreach ($aContexts as $key => $sLabel) { $oPdf->SetX($xMin + $fIconSize + $fPadding); $oPdf->Cell(0, $fIconSize + 2 * $fPadding, $sLabel, 0, 1); $oPdf->Image($aContextIcons[$key], $xMin + 1 + $fIconSize * 0.125, $yPos + $fIconSize * 0.125, $fIconSize * 0.75, $fIconSize * 0.75); $yPos += $fIconSize + 2 * $fPadding; } $oPdf->Rect($xMin, $yMin, $fMaxWidth + $fIconSize + 3 * $fPadding, $yMax - $yMin, 'D'); if ($sComments != '') { // Draw the comment text (surrounded by a rectangle) $xPos = $xMin + $fMaxWidth + $fIconSize + 4 * $fPadding; $w = $xMax - $xPos - 2 * $fPadding; $iNbLines = 1; $sText = '<p>' . str_replace("\n", '<br/>', htmlentities($sComments, ENT_QUOTES, 'UTF-8'), $iNbLines) . '</p>'; $fLineHeight = $oPdf->getStringHeight($w, $sText); $h = (1 + $iNbLines) * $fLineHeight; $yPos = $yMax - 2 * $fPadding - $h; $oPdf->writeHTMLCell($w, $h, $xPos + $fPadding, $yPos + $fPadding, $sText, 0, 1); $oPdf->Rect($xPos, $yPos, $w + 2 * $fPadding, $h + 2 * $fPadding, 'D'); $yMax = $yPos - $fPadding; } return array('xmin' => $xMin + $fMaxWidth + $fIconSize + 4 * $fPadding, 'xmax' => $xMax, 'ymin' => $yMin, 'ymax' => $yMax); }