private function printPDF($customer_id, $post_device, $post_user, $comment, $username, $randomcode, $date) { require_once Mage::getBaseDir('lib') . '/tcpdf/tcpdf.php'; // create new PDF docume, nt $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set font $pdf->SetFont('helvetica', '', 11); // add a page $pdf->AddPage(); $pdf->setJPEGQuality(100); // set cell padding $pdf->setCellPaddings(0, 0, 0, 0); $pdf->SetLineWidth(0.2); // set cell margins $pdf->setCellMargins(0, 0, 0, 0); $pdf->setCellHeightRatio(1); // set color for background $pdf->SetFillColor(255, 255, 255); // Multicell // MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0) // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M') $pdf->SetFont('helvetica', '', 11); $pdf->MultiCell(50, 0, 'SERVISNI LIST - REVERS', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->SetFont('helvetica', '', 8); $pdf->MultiCell(100, 0, 'GAMEBOX, Cara Dušana 47, Niš - tel 018/514-666 - 060/514-666-0', 0, 'L', 1, 0, 80, $pdf->getY() + 1, true, 0, false); // Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false) // $pdf->Image(dirname(__FILE__). '/bcimages/'. $randkey . '.png',80,8,100,8,'','','',true); $pdf->Image(Mage::getBaseDir('media') . '/pdf/gbr.png', 182, 10, 20, 60, '', '', '', true); $pdf->Ln(); $pdf->Ln(); $pdf->SetFont('helvetica', '', 8); $pdf->Cell(70, 6, 'Naziv uredjaja', 0, 0, 'L', 0); $pdf->Cell(40, 6, 'Serijski broj', 0, 0, 'L', 0); $pdf->Cell(60, 6, 'Opis kvara', 0, 0, 'L', 0); $pdf->Ln(); $i = 1; foreach ($post_device as $key => $post) { if ($i == 1) { $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'LT', 'L', 1, 0, 10, '', true, 0, false); $pdf->MultiCell(40, 6, $post['sn'], 'T', 'L', 1, 0, 80, '', true, 0, false); $pdf->MultiCell(60, 6, $post['description'], 'TR', 'L', 1, 0, 120, '', true, 0, false); } else { $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'L', 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(40, 6, $post['sn'], 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(60, 6, $post['description'], 'R', 'L', 1, 0, '', '', true, 0, false); } $pdf->Ln(); ++$i; } //$pdf->MultiCell(70, 15, ' 1. ' . $naziv1, 'LT', 'L', 1, 0, 10, '', true, 0, false); //$pdf->MultiCell(40, 15, $_POST['sn1'], 'T', 'L', 1, 0, 80, '', true, 0, false); //$pdf->MultiCell(60, 15, $opis1, 'TR', 'L', 1, 0, 120, '', true, 0, false); //$pdf->Ln(); $pdf->MultiCell(70, 1, ' ', 'LB', 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(40, 1, ' ', 'B', 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(60, 1, ' ', 'RB', 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->Cell(70, 6, 'Dodatna uputstva / komentari', 0, 0, 'L', 0); $pdf->Ln(); $pdf->MultiCell(170, 5, $comment, 'TRLB', 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->Cell(70, 6, 'Na servis predao', 0, 0, 'L', 0); $pdf->Ln(); $pdf->Ln(); $pdf->MultiCell(20, 6, 'Ime:', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 6, $post_user['name'], 0, 'L', 1, 0, 25, '', true, 0, false); $pdf->MultiCell(50, 6, 'Datum i vreme prijema:', 0, 'L', 1, 0, 70, '', true, 0, false); $pdf->MultiCell(50, 6, $date, 0, 'L', 1, 0, 100, '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(20, 6, 'Email:', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 6, $post_user['email'], 0, 'L', 1, 0, 25, '', true, 0, false); $pdf->MultiCell(50, 6, 'Kontrolni kod:', 0, 'L', 1, 0, 70, '', true, 0, false); $pdf->MultiCell(50, 6, $randomcode, 0, 'L', 1, 0, 100, '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(20, 6, 'Telefon:', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 6, $post_user['phone'], 0, 'L', 1, 0, 25, '', true, 0, false); $pdf->MultiCell(120, 6, 'Pratite stanje Vašeg uredjaja na servisu.<br>Posetite <b>http://proveraservisa.gamebox.co.rs/</b> i unesite Vaš kontrolni kod<br />ili skenirajte <b>QR</b> kod pomocu Vašeg mobilnog telefona', 0, 'L', 1, 0, 70, '', true, 0, true); $pdf->Ln(); $pdf->Ln(3); $pdf->MultiCell(110, 10, "\n" . Mage::getStoreConfig('servisnilist/text/upozorenje'), 1, 'C', 1, 0, 50, '', true, 0, false); $pdf->Ln(); if (count($post_device) == 1) { $pdf->Ln(); } $pdf->Ln(5); $pdf->Image(Mage::getBaseDir('media') . '/pdf/cut-here.png', 3, '', 250, 3, '', '', '', false, 300, '', false, false, 0, true); $pdf->Ln(9); $x = $pdf->GetX(); $y = $pdf->GetY(); // bottom part $pdf->SetFont('helvetica', '', 11); $pdf->MultiCell(50, 8, 'SERVISNI LIST - REVERS', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->SetFont('helvetica', '', 8); $pdf->MultiCell(100, 0, 'GAMEBOX, Cara Dušana 47, Niš - tel 018/514-666 - 060/514-666-0', 0, 'L', 1, 0, 80, '', true, 0, false); $pdf->Ln(); $pdf->Ln(); $pdf->SetFont('helvetica', '', 8); $pdf->Cell(70, 6, 'Naziv uredjaja', 0, 0, 'L', 0); $pdf->Cell(40, 6, 'Serijski broj', 0, 0, 'L', 0); $pdf->Cell(60, 6, 'Opis kvara', 0, 0, 'L', 0); $pdf->Ln(); $i = 1; foreach ($post_device as $key => $post) { if ($i == 1) { $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'LT', 'L', 1, 0, 10, '', true, 0, false); $pdf->MultiCell(40, 6, $post['sn'], 'T', 'L', 1, 0, 80, '', true, 0, false); $pdf->MultiCell(60, 6, $post['description'], 'TR', 'L', 1, 0, 120, '', true, 0, false); } else { $pdf->MultiCell(70, 6, ' ' . $i . '. ' . $post['name'], 'L', 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(40, 6, $post['sn'], 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(60, 6, $post['description'], 'R', 'L', 1, 0, '', '', true, 0, false); } $pdf->Ln(); ++$i; } $pdf->MultiCell(70, 1, ' ', 'LB', 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(40, 1, ' ', 'B', 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(60, 1, ' ', 'RB', 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->Cell(70, 6, 'Dodatna uputstva / komentari', 0, 0, 'L', 0); $pdf->Ln(); $pdf->MultiCell(170, 5, $comment, 'TRLB', 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->Cell(70, 6, 'Obracun', 0, 0, 'L', 0); $pdf->Ln(); $pdf->Cell(90, 6, 'Materijal', 0, 0, 'L', 0); $pdf->Cell(20, 6, 'j. mere', 0, 0, 'L', 0); $pdf->Cell(15, 6, 'kolicina', 0, 0, 'L', 0); $pdf->Cell(20, 6, 'cena', 0, 0, 'L', 0); $pdf->Cell(25, 6, 'UKUPNO', 0, 0, 'L', 0); $pdf->Ln(); $pdf->Cell(90, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(15, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(25, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Ln(); $pdf->Cell(90, 6, 'Opis usluge', 0, 0, 'L', 0); $pdf->Cell(20, 6, 'j. mere', 0, 0, 'L', 0); $pdf->Cell(15, 6, 'kolicina', 0, 0, 'L', 0); $pdf->Cell(20, 6, 'cena', 0, 0, 'L', 0); $pdf->Cell(25, 6, 'UKUPNO', 0, 0, 'L', 0); $pdf->Ln(); $pdf->Cell(90, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(15, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(20, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Cell(25, 5, ' ', 'TRLB', 0, 'L', 0); $pdf->Ln(); $pdf->MultiCell(60, 6, 'SVEGA:', 'B', 'L', 1, 0, 120, $pdf->getY() + 1, true, 0, false); $pdf->Ln(); $pdf->Cell(70, 6, 'Na servis predao', 0, 0, 'L', 0); $pdf->Ln(); $pdf->MultiCell(20, 6, 'Ime:', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 6, $post_user['name'], 0, 'L', 1, 0, 25, '', true, 0, false); $pdf->MultiCell(50, 6, 'Datum i vreme prijema:', 0, 'L', 1, 0, 70, '', true, 0, false); $pdf->MultiCell(50, 6, $date, 0, 'L', 1, 0, 100, '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(20, 6, 'Email:', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 6, $post_user['email'], 0, 'L', 1, 0, 25, '', true, 0, false); $pdf->MultiCell(50, 6, 'Kontrolni kod:', 0, 'L', 1, 0, 70, '', true, 0, false); $pdf->MultiCell(50, 6, $randomcode, 0, 'L', 1, 0, 100, '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(20, 6, 'Telefon:', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 6, $post_user['phone'], 0, 'L', 1, 0, 25, '', true, 0, false); //$pdf->Image(dirname(__FILE__) . '/bcimages/' . $randkey . '.png', 66, $pdf->getY() - 2, 100, 8, '', '', '', true, 300, '', false, false, 0, false); // $pdf->MultiCell(120, 6, 'Pratite stanje Vaseg uredjaja na servisu.<br>Posetite <b>http://bengazi.com/proveraservisa</b> i unesite Vas kontrolni kod' ,0, 'L', 1, 0, 70, '', true, 0, true); $pdf->Ln(); $pdf->MultiCell(20, 6, 'Potpis:', 0, 'L', 1, 0, '', '', true, 0, false); // CODE 128 B // define barcode style $style1d = array('position' => 'S', 'align' => 'C', 'stretch' => false, 'fitwidth' => true, 'cellfitalign' => '', 'border' => false, 'hpadding' => '35', 'vpadding' => '30', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'text' => false, 'font' => 'helvetica', 'fontsize' => 8, 'stretchtext' => 4); $pdf->setXY(180, $y + 35); //155 $pdf->StartTransform(); $pdf->Rotate(90); $pdf->write1DBarcode($randomcode, 'C128B', '', '', '', 14, 0.5, $style1d, 'T'); $pdf->StopTransform(); // new style $styleQR = array('border' => false, 'padding' => 0, 'fgcolor' => array(0, 0, 0), 'bgcolor' => false); // QRCODE,H : QR-CODE Best error correction $pdf->write2DBarcode('http://proveraservisa.gamebox.co.rs/?kk=' . $randomcode, 'QRCODE,H', 184, 75, 50, 50, $styleQR, 'N'); // QRCODE,H : QR-CODE Best error correction $pdf->write2DBarcode(Mage::getBaseUrl() . 'servisnilist/status/qr/slid/' . $customer_id, 'QRCODE,H', 184, $y + 65, 50, 50, $styleQR, 'N'); // Close and output PDF document $pdf->IncludeJS('print();'); // die('y'); //ob_clean(); //stupid tcpdf need this $pdf->Output('trt.pdf', 'I'); exit; }
/** * Draws a rectangle at x1,y1 with width w and height h * * See {@link Style::munge_colour()} for the format of the colour array. * See {@link Cpdf::setLineStyle()} for a description of the $style * parameter (aka dash) * * @param float $x1 * @param float $y1 * @param float $w * @param float $h * @param array $color * @param float $width * @param array $style */ function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { if (is_null($this->_last_line_width) || $width != $this->_last_line_width) { $this->_pdf->SetLineWidth($width); $this->_last_line_width = $width; } $this->_set_stroke_colour($color); // FIXME: ugh, need to handle styles here $this->_pdf->rect($x1, $y1, $w, $h); }
public function __construct() { // $orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false $pdf = new \TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont('courier'); $pdf->SetMargins(10, 10, 7, true); $pdf->SetAutoPageBreak(true, 5); $pdf->setImageScale(1); $pdf->SetFont('freeserif', '', 12, '', false); $pdf->SetLineWidth(0.05); $this->pdf = $pdf; $this->cell = new cell($this->pdf); }
// set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'B', 20); // add a page $pdf->AddPage(); $pdf->Write(0, 'Example of alignment options for Cell()', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 11); // set border width $pdf->SetLineWidth(0.7); // set color for cell border $pdf->SetDrawColor(0, 128, 255); $pdf->setCellHeightRatio(3); $pdf->SetXY(15, 60); // text on center $pdf->Cell(30, 0, 'Top-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'T', 'C'); $pdf->Cell(30, 0, 'Center-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'C', 'C'); $pdf->Cell(30, 0, 'Bottom-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'B', 'C'); $pdf->Cell(30, 0, 'Ascent-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'A', 'C'); $pdf->Cell(30, 0, 'Baseline-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'L', 'C'); $pdf->Cell(30, 0, 'Descent-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'D', 'C'); $pdf->SetXY(15, 90); // text on top $pdf->Cell(30, 0, 'Top-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'T', 'T'); $pdf->Cell(30, 0, 'Center-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'C', 'T');
//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 font $pdf->SetFont('helvetica', "B", 12); // add a page $pdf->AddPage(); $pdf->SetLineWidth(1); $pdf->SetDrawColor(50, 0, 0, 0); $pdf->SetFillColor(100, 0, 0, 0); $pdf->SetTextColor(100, 0, 0, 0); $pdf->Rect(30, 60, 20, 20, 'DF'); $pdf->Text(30, 85, 'Cyan'); $pdf->SetDrawColor(0, 50, 0, 0); $pdf->SetFillColor(0, 100, 0, 0); $pdf->SetTextColor(0, 100, 0, 0); $pdf->Rect(60, 60, 20, 20, 'DF'); $pdf->Text(60, 85, 'Magenta'); $pdf->SetDrawColor(0, 0, 50, 0); $pdf->SetFillColor(0, 0, 100, 0); $pdf->SetTextColor(0, 0, 100, 0); $pdf->Rect(90, 60, 20, 20, 'DF'); $pdf->Text(90, 85, 'Yellow');
//set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'BI', 8); // add a page $pdf->AddPage(); /* * setAlpha() gives transparency support. You can set the * alpha channel from 0 (fully transparent) to 1 (fully * opaque). It applies to all elements (text, drawings, * images). */ $pdf->SetLineWidth(1.5); // draw opaque red square $pdf->SetFillColor(255, 0, 0); $pdf->Rect(30, 60, 40, 40, 'DF'); // set alpha to semi-transparency $pdf->SetAlpha(0.5); // draw green square $pdf->SetFillColor(0, 255, 0); $pdf->Rect(40, 70, 40, 40, 'DF'); // draw jpeg image $pdf->Image('../images/image_demo.jpg', 50, 80, 40, 40, '', 'http://www.tcpdf.org', '', true, 72); // restore full opacity $pdf->SetAlpha(1); // print name $pdf->Text(55, 85, 'TRANSPARENCY'); // ---------------------------------------------------------
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 025'); $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 . ' 025', 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('helvetica', '', 12); // add a page $pdf->AddPage(); $txt = 'You can set the transparency of PDF objects using the setAlpha() method.'; $pdf->Write(0, $txt, '', 0, '', true, 0, false, false, 0); /* * setAlpha() gives transparency support. You can set the * alpha channel from 0 (fully transparent) to 1 (fully * opaque). It applies to all elements (text, drawings, * images). */ $pdf->SetLineWidth(2); // draw opaque red square $pdf->SetFillColor(255, 0, 0); $pdf->SetDrawColor(127, 0, 0); $pdf->Rect(30, 40, 60, 60, 'DF'); // set alpha to semi-transparency $pdf->SetAlpha(0.5); // draw green square $pdf->SetFillColor(0, 255, 0); $pdf->SetDrawColor(0, 127, 0); $pdf->Rect(50, 60, 60, 60, 'DF'); // draw blue square $pdf->SetFillColor(0, 0, 255); $pdf->SetDrawColor(0, 0, 127); $pdf->Rect(70, 80, 60, 60, 'DF'); // draw jpeg image $pdf->Image('tests/images/image_demo.jpg', 90, 100, 60, 60, '', 'http://www.tcpdf.org', '', true, 72); // restore full opacity $pdf->SetAlpha(1); $this->comparePdfs($pdf); }
public function rekapitulasi_lahan_kecamatan_pdf($tahun, $periode) { /// create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Dinas PU CKTR Sidoarjo'); $pdf->SetTitle('Rekapitulasi_Lahan_Perkecamatan_Triwulan' . $periode . '_' . $tahun); $pdf->SetSubject('TCPDF'); $pdf->SetKeywords('TCPDF, PDF'); $pdf->SetHeaderData('sidoardjo.png', 20, 'PEMERINTAH KABUPATEN SIDOARDJO', 'DINAS PEKERJAAN UMUM CIPTA KARYA DAN TATA RUANG', 'REKAPITULASI DATA LAHAN PERUMAHAH / PEMUKIMAN'); $pdf->setFooterData('Triwulan ' . $periode . ' Tahun ' . $tahun); $pdf->setBarcode(date('Y-m-d H:i:s')); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'B', 20); // add a page $pdf->AddPage('L', 'A3'); // $pdf->Write(0, 'PEMBANGUNAN PERUMAHAN / PEMUKIMAN', '', 0, 'C', true, 0, false, false, 0); // $pdf->Write(0, 'REKAPITULASI DATA LAHAN PERUMAHAH / PEMUKIMAN', '', 0, 'C', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 11); // $pdf->Write(0, 'Tahun :' .$tahun, '', 0, 'L', true, 0, false, false, 0); // $pdf->Write(0, 'Periode : Triwulan' .$periode, '', 0, 'L', true, 0, false, false, 0); $pdf->SetLineWidth(5); $pdf->SetDrawColor(0, 128, 255); $pdf->SetFillColor(255, 255, 128); // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- $k['JML_IJIN_LOKASI'] = $k['LUAS'] = $k['RENCANA_TAPAK'] = $k['PEMBEBASAN'] = $k['TERBANGUN'] = $k['BELUM_TERBANGUN'] = $k['DIALOKASIKAN'] = $k['PEMBEBASAN'] = $k['DIMATANGKAN'] = $k['AKTIF_DLM_PEMBANGUNAN'] = $k['AKTIF_BERHENTI'] = $k['AKTIF_SDH_SELESAI'] = $k['TIDAK_AKTIF'] = 0; $tb = ""; $this->load->model('m_report'); $nilai = $this->m_report->jumlah_kecamatan(); foreach ($nilai as $nil) { $jmlkec = $nil['JUMLAH']; $data['jumlah'] = $nil['JUMLAH']; } for ($j = 1; $j <= $jmlkec; $j++) { $data['lah_kec'][$j] = $this->m_report->tabel_lahan_kecamatan_all($j, $tahun, $periode); $data['aktifpemb'][$j] = $this->m_report->aktif_dalam_pembangunan($j, $tahun, $periode); $data['aktifber'][$j] = $this->m_report->aktif_berhenti($j, $tahun, $periode); $data['aktifsel'][$j] = $this->m_report->aktif_sdh_selesai($j, $tahun, $periode); $data['tdkaktif'][$j] = $this->m_report->tidak_aktif($j, $tahun, $periode); } for ($c = 1; $c < $jmlkec; $c++) { foreach ($data['lah_kec'][$c] as $i) { $tb .= "<tr>\n <td width=\"28px\">" . $c . "</td>\n <td width=\"100px\">" . $i['NAMA_KECAMATAN'] . "</td> \n <td width=\"87px\">" . $i['JML_IJIN_LOKASI'] . " </td>\n <td width=\"87px\">" . $i['LUAS'] . " </td>\n <td width=\"87px\">" . $i['RENCANA_TAPAK'] . " </td>\n <td width=\"90px\">" . $i['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $i['TERBANGUN'] . " </td>\n <td width=\"87px\">" . $i['BELUM_TERBANGUN'] . " </td>\n <td width=\"90px\">" . $i['DIALOKASIKAN'] . " </td>\n <td width=\"90px\">" . $i['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $i['DIMATANGKAN'] . " </td>"; $k['JML_IJIN_LOKASI'] += $i['JML_IJIN_LOKASI']; $k['LUAS'] += $i['LUAS']; $k['RENCANA_TAPAK'] += $i['RENCANA_TAPAK']; $k['PEMBEBASAN'] += $i['PEMBEBASAN']; $k['TERBANGUN'] += $i['TERBANGUN']; $k['BELUM_TERBANGUN'] += $i['BELUM_TERBANGUN']; $k['DIALOKASIKAN'] += $i['DIALOKASIKAN']; $k['PEMBEBASAN'] += $i['PEMBEBASAN']; $k['DIMATANGKAN'] += $i['DIMATANGKAN']; } foreach ($data['aktifpemb'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['AKTIF_DLM_PEMBANGUNAN'] . "</td>"; $k['AKTIF_DLM_PEMBANGUNAN'] += $i['AKTIF_DLM_PEMBANGUNAN']; } foreach ($data['aktifber'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['AKTIF_BERHENTI'] . " </td>"; $k['AKTIF_BERHENTI'] += $i['AKTIF_BERHENTI']; } foreach ($data['aktifsel'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['AKTIF_SDH_SELESAI'] . " </td>"; $k['AKTIF_SDH_SELESAI'] += $i['AKTIF_SDH_SELESAI']; } foreach ($data['tdkaktif'][$c] as $i) { $tb .= "<td width=\"87px\">" . $i['TIDAK_AKTIF'] . " </td> \n </tr> "; $k['TIDAK_AKTIF'] += $i['TIDAK_AKTIF']; } } $tb1 = ""; $tb1 .= "<tr>\n \n <td width=\"130px\">JUMLAH</td>\n <td width=\"87px\">" . $k['JML_IJIN_LOKASI'] . " </td>\n <td width=\"87px\">" . $k['LUAS'] . " </td>\n <td width=\"87px\">" . $k['RENCANA_TAPAK'] . " </td>\n <td width=\"90px\">" . $k['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $k['TERBANGUN'] . " </td>\n <td width=\"87px\">" . $k['BELUM_TERBANGUN'] . " </td>\n <td width=\"90px\">" . $k['DIALOKASIKAN'] . " </td>\n <td width=\"90px\">" . $k['PEMBEBASAN'] . " </td>\n <td width=\"87px\">" . $k['DIMATANGKAN'] . " </td>\n <td width=\"87px\">" . $k['AKTIF_DLM_PEMBANGUNAN'] . " </td>\n <td width=\"87px\">" . $k['AKTIF_BERHENTI'] . " </td>\n <td width=\"87px\">" . $k['AKTIF_SDH_SELESAI'] . " </td>\n <td width=\"87px\">" . $k['TIDAK_AKTIF'] . " </td>\n \n </tr> "; $tbl = <<<EOD <table border="1" cellpadding="2" cellspacing="2"> <thead> <tr style="background-color:#FFFF00;color:#0000FF;"> <td width="28px" align="center"><b>NO</b></td> <td width="100px" align="center"><b>Kecamatan</b></td> <td width="87px " align="center"> <b>Perusahaan</b></td> <td width="87px" align="center"><b>Nama Perumahaan</b></td> <td width="87px" align="center"><b>Nama Lokasi (Ha)</b></td> <td width="87px" align="center"><b>No Lokasi</b></td> <td width="87px" align="center"><b>Tanggal Lokasi Dimiliki</b></td> <td width="87px" align="center"><b>Luas Lokasi</b></td> <td width="87px" align="center"><b>Rencana Tapak</b></td> <td width="90px" align="center"><b>Pembebasan</b></td> <td width="87px" align="center"><b>Terbangun</b></td> <td width="87px" align="center"><b>Belum Terbangun</b></td> <td width="90px" align="center"><b>Dialokasikan</b></td> <td width="90px" align="center"><b>Pembebasan</b></td> <td width="87px" align="center"><b>Sudah Dimatangkan</b></td> </tr> </thead> {$tb} {$tb1} </table> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); $tb = ""; $tb1 = ""; $this->load->model('m_report'); $data1 = $this->m_report->tabel_lahan_kecamatan_all_statistic($tahun - 1); $data2 = $this->m_report->tabel_lahan_kecamatan_all_statistic($tahun - 2); foreach ($data2 as $i) { $tb .= "<tr> \n \n <td width=\"320px\">JUMLAH PENGEMBANG\n <br>JUMLAH IJIN LOKASI\n <br>LUAS IJIN LOKASI\n <br>RENCANA TAPAK\n <br>PEMBEBASAN\n <br>TERBANGUN\n <br>BELUM TERBANGUN\n </td>\n <td width=\"200px\">" . $i['JML_PENGEMBANG'] . "\n <br>" . $i['JML_IJIN_LOKASI'] . "\n <br>" . $i['LUAS'] . "\n <br>" . $i['RENCANA_TAPAK'] . "\n <br>" . $i['PEMBEBASAN'] . "\n <br>" . $i['TERBANGUN'] . "\n <br>" . $i['BELUM_TERBANGUN'] . "\n </td>"; } foreach ($data1 as $i) { $tb .= "<td width=\"200px\">" . $i['JML_PENGEMBANG'] . "\n <br>" . $i['JML_IJIN_LOKASI'] . "\n <br>" . $i['LUAS'] . "\n <br>" . $i['RENCANA_TAPAK'] . "\n <br>" . $i['PEMBEBASAN'] . "\n <br>" . $i['TERBANGUN'] . "\n <br>" . $i['BELUM_TERBANGUN'] . "\n </td> \n </tr> "; } $th1 = $tahun - 1; $th2 = $tahun - 2; $tbl = <<<EOD <table border="1" cellpadding="2" cellspacing="2"> <thead> <tr style="background-color:#FFFF00;color:#0000FF;"> <td width="320px" align="center"><b>TYPE RUMAH</b></td> <td width="200px " align="center"> <b>DES {$th2}</b></td> <td width="200px " align="center"> <b>DES {$th1}</b></td> </tr> </thead> {$tb} {$tb1} </table> EOD; //print_r($tbl); $pdf->writeHTML($tbl, true, false, false, false, ''); $pdf->Output('Rekapitulasi_Lahan_Perkecamatan_Triwulan' . $periode . '_' . $tahun . '.pdf', 'I'); }
public function printTableAsPdf() { global $CFG; define('K_PATH_CACHE', $CFG->dataroot . '/temp/'); require_once gcr::webDir . 'lib/tcpdf/config/lang/eng.php'; require_once gcr::webDir . 'lib/tcpdf/tcpdf.php'; $app = $this->user->getApp(); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator($app->getFullName()); $pdf->SetAuthor($app->getFullName()); $pdf->SetTitle('Student Transcript'); $pdf->SetSubject($this->user->getFullNameString()); $pdf->SetKeywords('transcript, course, grade'); $address = $app->getAddressObject(); $person2 = $app->getPerson2Object(); $header_string = $person2->getFullName() . "\n"; $header_string .= $address->getStreet1() . "\n"; if ($address->getStreet2() != '') { $header_string .= $address->getStreet2() . "\n"; } $header_string .= $address->getCity() . ', ' . $address->getState() . ' ' . $address->getZipcode() . "\n"; $header_string .= $person2->getPhone1() . "\n"; $header_string .= $person2->getPhone2() . "\n"; $header_string .= $person2->getEmail(); // set default header data $pdf->SetHeaderData('../../../../../../..' . $app->getLogoFilePath(), 30, trim(trim($app->getFullName())) . ' Student Transcript', 'Student: ' . trim($this->user->getFullNameString()) . ', ' . $this->user->getObject()->email . "\nDate: " . date('m/d/Y', time())); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', '', 8); // add a page $pdf->AddPage(); $mdl_user_obj = $this->user->getObject(); $html = '<b>Educational Provider Information:</b><br />'; $html .= $app->getFullName() . '<br />'; $html .= $person2->getFullName() . '<br />'; $html .= $address->getStreet1() . '<br />'; if ($address->getStreet2() != '') { $html .= $address->getStreet2() . "<br />"; } $html .= $address->getCity() . ', ' . $address->getState() . ' ' . $address->getZipcode() . "<br />"; $html .= $person2->getPhone1() . "<br />"; $html .= $person2->getPhone2() . "<br />"; $html .= $person2->getEmail() . '<br /><br />'; $w = array(17, 65, 50, 12, 12, 23); $pdf->SetFillColor(255); $pdf->SetTextColor(0); // Data $fill = 0; $pdf->writeHTMLCell(array_sum($w), $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true); $pdf->SetFont('helvetica', '', 8); $row_count = $this->table->getRowCount(); $columns = $this->table->getColumns(); // Colors, line width and bold font $pdf->SetFillColor(230, 238, 238); $pdf->SetDrawColor(221, 221, 221); $pdf->SetLineWidth(0.3); $pdf->SetFont('', 'B', 8); // Header $pdf->Cell($w[0], 7, 'Date', 1, 0, 'L', 1); $pdf->Cell($w[1], 7, 'Course', 1, 0, 'L', 1); $pdf->Cell($w[2], 7, 'Instructor', 1, 0, 'L', 1); $pdf->Cell($w[3], 7, 'Credits', 1, 0, 'L', 1); $pdf->Cell($w[4], 7, 'Grade', 1, 0, 'L', 1); $pdf->Cell($w[5], 7, 'Result', 1, 0, 'L', 1); $pdf->Ln(); // Color and font restoration $pdf->SetFillColor(240, 240, 246); $pdf->SetFont('helvetica', '', 8); // Data $fill = 0; // This convoluted code does the following for each table row: // 1. Break the table row contents into a multidimentional // array, $row[column][line], so that we can handle cells // which require multiple lines because they are too long. // 2. Print each column left to right, and repeat for each line // required for this row. for ($row = 1; $row < $row_count; $row++) { $row_content = array(); $max_line_index = 0; for ($column = 0; $column < 6; $column++) { $max_chars = floor(0.75 * $w[$column]); $cell_content = strip_tags($columns[$column]->getCells($row)->getContent()); $column_line_count = ceil((strlen($cell_content) + 0.1) / $max_chars); if ($column_line_count - 1 > $max_line_index) { $max_line_index = $column_line_count - 1; } for ($i = 0; $i < $column_line_count; $i++) { $row_content[$column][$i] = substr($cell_content, $max_chars * $i, $max_chars); } } for ($i = 0; $i <= $max_line_index; $i++) { for ($column = 0; $column < 6; $column++) { if (!isset($row_content[$column][$i])) { $row_content[$column][$i] = ''; } $pdf->Cell($w[$column], 6, $row_content[$column][$i], 'LR', 0, 'L', $fill); } $pdf->Ln(); } $fill = !$fill; } $pdf->SetFont('helvetica', '', 7); $html = '*Note: This transcript may not include all course records for the specified user. Neither Globalclassroom Inc. nor the educational provider can verify the accuracy of the grades listed and cannot be held responsible for any usage of this document or the information provided therein.'; $pdf->Cell(array_sum($w), 0, '', 'T'); $pdf->Ln(); $pdf->writeHTMLCell(array_sum($w), $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('transcript.pdf', 'I'); }
/** * print PDF order * @param Order $order */ private function printPDFOrder(Order $order){ global $lang; $product_items = $order->getProducts(); $shop = new ShopInfo($this->module_srl); $this->model->includeTCPDF(); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, TRUE, 'UTF-8', FALSE); // set document information $pdf->SetCreator($shop->getShopTitle()); $pdf->SetTitle(sprintf($lang->order_with_number, $order->order_srl)); $pdf->SetSubject(sprintf($lang->order_with_number, $order->order_srl)); $pdf->setPrintHeader(FALSE); $pdf->setPrintFooter(FALSE); // set font $pdf->SetFont('dejavusans', '', 10); // add a page $pdf->AddPage(); // create HTML content $html = ' <div style="float:left; text-align: center;">'.$shop->getShopTitle().'</div> <h1>'.sprintf($lang->order_with_number, $order->order_srl).'</h1> <p></p> Order date: '.zdate($order->regdate,'d-M-y').' <p></p><h3>'.$lang->shipping_address.'</h3>'.$order->shipping_address.' <p></p><h3>'.$lang->billing_address.'</h3>'.$order->billing_address.' <p></p><h3>'.$lang->payment_method_used.'</h3>'.ucwords(str_replace('_', ' ', $order->payment_method)).' <p></p><h3>'.$lang->shipping_method_used.'</h3>'.ucwords(str_replace('_', ' ', $order->shipping_method)).' <p></p><h3>'.$lang->items_ordered.'</h3></br>'; // output the HTML content $pdf->writeHTML($html, TRUE, FALSE, TRUE, FALSE, ''); // Colors, line width and bold font $pdf->SetFillColor(38, 74, 108); $pdf->SetTextColor(255); $pdf->SetDrawColor(38, 74, 108); $pdf->SetLineWidth(0.3); $pdf->SetFont('', 'B'); // Header $w = array(15, 70, 20, 45, 45); $header= $header = array($lang->product_no_dot, $lang->title, $lang->quantity, $lang->price, $lang->subtotal); $num_headers = count($header); for($i = 0; $i < $num_headers; ++$i) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1); } $pdf->Ln(); // Color and font restoration $pdf->SetFillColor(224, 235, 255); $pdf->SetTextColor(0); $pdf->SetFont(''); // Data $fill = 0; $i = 0; foreach($product_items as $product){ $i++; $pdf->Cell($w[0], 6, $i, 'LR', 0, 'C', $fill); $pdf->Cell($w[1], 6, $product->getTitle(), 'LR', 0, 'L', $fill); $pdf->Cell($w[2], 6, $product->getQuantity(), 'LR', 0, 'R', $fill); $pdf->Cell($w[3], 6, ShopDisplay::priceFormat($product->getPrice(), $shop->getCurrencySymbol()), 'LR', 0, 'R', $fill); $pdf->Cell($w[4], 6, ShopDisplay::priceFormat($product->getPrice() * $product->getQuantity(), $shop->getCurrencySymbol()), 'LR', 0, 'R', $fill); $pdf->Ln(); $fill=!$fill; } $pdf->Cell(array_sum($w) - $w[4], 6, $lang->total, 1, 0, 'R',$fill); $pdf->Cell($w[4], 6, ShopDisplay::priceFormat($order->getTotalBeforeDiscount(), $shop->getCurrencySymbol()), 1, 0, 'R',$fill); $fill=!$fill; $pdf->Ln(); if($order->getDiscountAmount()){ $pdf->Cell(array_sum($w) - $w[4], 6, $lang->discount, 1, 0, 'R',$fill); $pdf->Cell($w[4], 6, ShopDisplay::priceFormat(-1 * $order->getDiscountAmount(), $shop->getCurrencySymbol()), 1, 0, 'R',$fill); $fill=!$fill; $pdf->Ln(); } if($order->getShippingMethodName()){ $pdf->Cell(array_sum($w) - $w[4], 6, $lang->shipping, 1, 0, 'R',$fill); $pdf->Cell($w[4], 6, ShopDisplay::priceFormat($order->getShippingCost(), $shop->getCurrencySymbol()), 1, 0, 'R',$fill); $fill=!$fill; $pdf->Ln(); } $pdf->SetFont('', 'B'); $pdf->Cell(array_sum($w) - $w[4], 6, $lang->grand_total, 1, 0, 'R',$fill); $pdf->Cell($w[4], 6, ShopDisplay::priceFormat($order->getTotal(), $shop->getCurrencySymbol()), 1, 0, 'R',$fill); $fill=!$fill; $pdf->Ln(); $pdf->SetFont(''); if($shop->showVAT()){ $pdf->Cell(array_sum($w) - $w[4], 6, $lang->taxes, 1, 0, 'R',$fill); $pdf->Cell($w[4], 6, ShopDisplay::priceFormat($order->getVAT(), $shop->getCurrencySymbol()), 1, 0, 'R',$fill); $fill=!$fill; $pdf->Ln(); } $pdf->Cell(array_sum($w), 0, '', 'T'); //Close and output PDF document $pdf->Output(sprintf($lang->order_with_number, $order->order_srl), 'I'); }
$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 font $pdf->SetFont('helvetica', 'B', 20); // add a page $pdf->AddPage(); $pdf->Write(0, 'Example of alignment options for Cell()', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 11); // set border width $pdf->SetLineWidth(0.7); // set color for cell border $pdf->SetDrawColor(0, 128, 255); $pdf->setCellHeightRatio(3); $pdf->SetXY(15, 60); // text on center $pdf->Cell(30, 0, 'Top-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'T', 'C'); $pdf->Cell(30, 0, 'Center-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'C', 'C'); $pdf->Cell(30, 0, 'Bottom-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'B', 'C'); $pdf->Cell(30, 0, 'Ascent-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'A', 'C'); $pdf->Cell(30, 0, 'Baseline-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'L', 'C'); $pdf->Cell(30, 0, 'Descent-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'D', 'C'); $pdf->SetXY(15, 90); // text on top $pdf->Cell(30, 0, 'Top-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'T', 'T'); $pdf->Cell(30, 0, 'Center-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'C', 'T');
public function PostAction() { $rma_ids = $this->getRequest()->getParam('povratnica'); if (!count($rma_ids)) { exit; } $broj_povratnice = Mage::helper('rma')->getBrojPovratnice(); $dobavljac = Mage::getModel('rma/rmadevices')->load($rma_ids[0])->getSupplier(); require_once Mage::getBaseDir('lib') . '/tcpdf/tcpdf.php'; // create new PDF document $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set font $pdf->SetFont('helvetica', '', 11); // add a page $pdf->AddPage(); $pdf->setJPEGQuality(100); // set cell padding $pdf->setCellPaddings(0, 0, 0, 0); $pdf->SetLineWidth(0.2); // set cell margins $pdf->setCellMargins(0, 0, 0, 0); $pdf->setCellHeightRatio(1); // set color for background $pdf->SetFillColor(255, 255, 255); // Multicell // MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0) // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M') $pdf->SetFont('helvetica', '', 11); $pdf->MultiCell(150, 0, 'BENGAZI DOO NIŠ, KRFSKA 18', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(100, 0, 'PIB: 104028469', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(100, 0, 'šifra delatnosti: 4666', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(100, 0, 'TR: 160-214265-03 / Banca Intesa a.d.', 0, 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->Ln(); $pdf->Ln(); $pdf->Ln(); $pdf->SetFont('helvetica', '', 16); $pdf->MultiCell(100, 0, 'Povratnica na servis ' . date("Y") . "/" . $broj_povratnice, 0, 'L', 1, 0, 65, '', true, 0, false); $pdf->Ln(); $pdf->Ln(); $pdf->Ln(); $pdf->Ln(); $pdf->SetFont('helvetica', '', 11); $pdf->MultiCell(100, 6, 'Niš, ' . date("j.n.Y"), 0, 'L', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 6, $dobavljac, 0, 'L', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->Ln(); $pdf->Ln(); $pdf->Ln(); $pdf->MultiCell(20, 8, "Redni broj", 'TL', 'C', 1, 0, '', '', true, 0, false); $pdf->MultiCell(70, 8, "Naziv artikla", 'LT', 'C', 1, 0, 30, '', true, 0, false); $pdf->MultiCell(20, 8, "jm", 'LT', 'C', 1, 0, 100, '', true, 0, false); $pdf->MultiCell(20, 8, "kolicina", 'LT', 'C', 1, 0, 120, '', true, 0, false); $pdf->MultiCell(60, 8, "Opis kvara", 'LTR', 'C', 1, 0, 140, '', true, 0, false); $pdf->Ln(); foreach ($rma_ids as $pos => $rbr) { $rma = Mage::getModel('rma/rmadevices')->load($rbr); $sn = $rma->getSerial() ? ' sn: ' . $rma->getSerial() : ''; $pdf->MultiCell(20, 8, $pos + 1, 'TL', 'C', 1, 0, '', '', true, 0, false); $pdf->MultiCell(70, 8, $rma->getName() . $sn, 'LT', 'C', 1, 0, 30, '', true, 0, false); $pdf->MultiCell(20, 8, "kom", 'LT', 'C', 1, 0, 100, '', true, 0, false); $pdf->MultiCell(20, 8, "1", 'LT', 'C', 1, 0, 120, '', true, 0, false); $pdf->MultiCell(60, 8, $rma->getDescription(), 'LTR', 'C', 1, 0, 140, '', true, 0, false); $pdf->Ln(); $rma->setDocumentId($broj_povratnice)->save(); } $pdf->MultiCell(190, 8, "", 'T', 'C', 1, 0, '', '', true, 0, false); $pdf->Ln(); $pdf->Ln(); $pdf->MultiCell(50, 5, "", 'B', 'C', 1, 0, '', '', true, 0, false); $pdf->MultiCell(20, 2, "mp", 0, 'C', 1, 0, 100, '', true, 0, false); $pdf->MultiCell(50, 5, "Predrag Stevanovic", 'B', 'C', 1, 0, 150, '', true, 0, false); $pdf->Ln(); $pdf->MultiCell(50, 10, "robu primio", 0, 'C', 1, 0, '', '', true, 0, false); $pdf->MultiCell(50, 10, "robu predao", 0, 'C', 1, 0, 150, '', true, 0, false); // Close and output PDF document $pdf->IncludeJS("print();"); //ob_clean(); //stupid tcpdf need this $pdf->Output(Mage::getBaseDir('media') . '/rma_pdf/' . $broj_povratnice . "-" . $dobavljac . '.pdf', 'FI'); exit; }
public function display($arraydata, $y_axis = 0, $fielddata = false) { //print_r($arraydata);echo "<br/>"; // $this->pdf->Cell(10,10,"SSSS"); $this->Rotate($arraydata["rotation"]); if ($arraydata["rotation"] != "") { if ($arraydata["rotation"] == "Left") { $w = $arraydata["width"]; $arraydata["width"] = $arraydata["height"]; $arraydata["height"] = $w; $this->pdf->SetXY($this->pdf->GetX() - $arraydata["width"], $this->pdf->GetY()); } elseif ($arraydata["rotation"] == "Right") { $w = $arraydata["width"]; $arraydata["width"] = $arraydata["height"]; $arraydata["height"] = $w; $this->pdf->SetXY($this->pdf->GetX(), $this->pdf->GetY() - $arraydata["height"]); } elseif ($arraydata["rotation"] == "UpsideDown") { //soverflow"=>$stretchoverflow,"poverflow" $arraydata["soverflow"] = true; $arraydata["poverflow"] = true; // $w=$arraydata["width"]; // $arraydata["width"]=$arraydata["height"]; //$arraydata["height"]=$w; $this->pdf->SetXY($this->pdf->GetX() - $arraydata["width"], $this->pdf->GetY() - $arraydata["height"]); } } if ($arraydata["type"] == "SetFont") { if ($arraydata["font"] == 'uGB') { $this->pdf->isUnicode = true; } else { $this->pdf->isUnicode = false; } $this->pdf->SetFont($arraydata["font"], $arraydata["fontstyle"], $arraydata["fontsize"]); } elseif ($arraydata["type"] == "subreport") { $this->runSubReport($arraydata); } elseif ($arraydata["type"] == "MultiCell") { $currenty = $this->pdf->GetY(); if ($fielddata == false) { if ($this->allowprintuntill >= $currenty) { $this->checkoverflow($arraydata, $this->updatePageNo($arraydata["txt"])); } } elseif ($fielddata == true) { if ($this->allowprintuntill >= $currenty) { $this->checkoverflow($arraydata, $this->updatePageNo($this->analyse_expression($arraydata["txt"], $arraydata["isPrintRepeatedValues"]))); } elseif ($this->parentcurrentband == "detail") { $this->pdf->Cell(40, 10, "SADSD"); } // echo $arraydata["txt"]."+\"|(".$y_axis.",".print_r($arraydata,true)."),$this->allowprintuntill,$newy\"<br/><br/>"; } } elseif ($arraydata["type"] == "SetXY") { $this->pdf->SetXY($arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis); } elseif ($arraydata["type"] == "Cell") { $currenty = $this->pdf->GetY(); if ($this->allowprintuntill >= $currenty) { $this->pdf->Cell($arraydata["width"], $arraydata["height"], $this->updatePageNo($arraydata["txt"]), $arraydata["border"], $arraydata["ln"], $arraydata["align"], $arraydata["fill"], $arraydata["link"]); } elseif ($this->parentcurrentband == "detail") { $this->pdf->Cell(40, 10, "SADSD"); } } elseif ($arraydata["type"] == "Rect") { $this->pdf->Rect($arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"]); } elseif ($arraydata["type"] == "Image") { $path = $this->analyse_expression($arraydata["path"]); $imgtype = substr($path, -3); if ($imgtype == 'jpg' || right($path, 3) == 'jpg' || right($path, 4) == 'jpeg') { $imgtype = "JPEG"; } elseif ($imgtype == 'png' || $imgtype == 'PNG') { $imgtype = "PNG"; } if (file_exists($path) || left($path, 4) == 'http') { $this->pdf->Image($path, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], $imgtype, $arraydata["link"]); } elseif (left($path, 22) == "data:image/jpeg;base64") { $imgtype = "JPEG"; $img = str_replace('data:image/jpeg;base64,', '', $path); $imgdata = base64_decode($img); $this->pdf->Image('@' . $imgdata, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"]); //,$imgtype,$arraydata["link"]); } elseif (left($path, 22) == "data:image/png;base64,") { $imgtype = "PNG"; // $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $img = str_replace('data:image/png;base64,', '', $path); $imgdata = base64_decode($img); $this->pdf->Image('@' . $imgdata, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"]); //,$imgtype,$arraydata["link"]); } } elseif ($arraydata["type"] == "SetTextColor") { $this->pdf->SetTextColor($arraydata["r"], $arraydata["g"], $arraydata["b"]); } elseif ($arraydata["type"] == "SetDrawColor") { $this->pdf->SetDrawColor($arraydata["r"], $arraydata["g"], $arraydata["b"]); } elseif ($arraydata["type"] == "SetLineWidth") { $this->pdf->SetLineWidth($arraydata["width"]); } elseif ($arraydata["type"] == "Line") { $this->pdf->Line($arraydata["x1"] + $this->arrayPageSetting["leftMargin"], $arraydata["y1"] + $y_axis, $arraydata["x2"] + $this->arrayPageSetting["leftMargin"], $arraydata["y2"] + $y_axis); } elseif ($arraydata["type"] == "SetFillColor") { $this->pdf->SetFillColor($arraydata["r"], $arraydata["g"], $arraydata["b"]); } elseif ($arraydata["type"] == "lineChart") { $this->showLineChart($arraydata, $y_axis); } elseif ($arraydata["type"] == "barChart") { $this->showBarChart($arraydata, $y_axis, 'barChart'); } elseif ($arraydata["type"] == "stackedBarChart") { $this->showBarChart($arraydata, $y_axis, 'stackedBarChart'); } elseif ($arraydata["type"] == "stackedAreaChart") { $this->showAreaChart($arraydata, $y_axis, $arraydata["type"]); } elseif ($arraydata["type"] == "Barcode") { $this->showBarcode($arraydata, $y_axis); } }
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 057'); $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 . ' 057', 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('helvetica', 'B', 20); // add a page $pdf->AddPage(); $pdf->Write(0, 'Example of alignment options for Cell()', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 11); // set border width $pdf->SetLineWidth(0.7); // set color for cell border $pdf->SetDrawColor(0, 128, 255); $pdf->setCellHeightRatio(3); $pdf->SetXY(15, 60); // text on center $pdf->Cell(30, 0, 'Top-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'T', 'C'); $pdf->Cell(30, 0, 'Center-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'C', 'C'); $pdf->Cell(30, 0, 'Bottom-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'B', 'C'); $pdf->Cell(30, 0, 'Ascent-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'A', 'C'); $pdf->Cell(30, 0, 'Baseline-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'L', 'C'); $pdf->Cell(30, 0, 'Descent-Center', 1, $ln = 0, 'C', 0, '', 0, false, 'D', 'C'); $pdf->SetXY(15, 90); // text on top $pdf->Cell(30, 0, 'Top-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'T', 'T'); $pdf->Cell(30, 0, 'Center-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'C', 'T'); $pdf->Cell(30, 0, 'Bottom-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'B', 'T'); $pdf->Cell(30, 0, 'Ascent-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'A', 'T'); $pdf->Cell(30, 0, 'Baseline-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'L', 'T'); $pdf->Cell(30, 0, 'Descent-Top', 1, $ln = 0, 'C', 0, '', 0, false, 'D', 'T'); $pdf->SetXY(15, 120); // text on bottom $pdf->Cell(30, 0, 'Top-Bottom', 1, $ln = 0, 'C', 0, '', 0, false, 'T', 'B'); $pdf->Cell(30, 0, 'Center-Bottom', 1, $ln = 0, 'C', 0, '', 0, false, 'C', 'B'); $pdf->Cell(30, 0, 'Bottom-Bottom', 1, $ln = 0, 'C', 0, '', 0, false, 'B', 'B'); $pdf->Cell(30, 0, 'Ascent-Bottom', 1, $ln = 0, 'C', 0, '', 0, false, 'A', 'B'); $pdf->Cell(30, 0, 'Baseline-Bottom', 1, $ln = 0, 'C', 0, '', 0, false, 'L', 'B'); $pdf->Cell(30, 0, 'Descent-Bottom', 1, $ln = 0, 'C', 0, '', 0, false, 'D', 'B'); // draw some reference lines $linestyle = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(255, 0, 0)); $pdf->Line(15, 60, 195, 60, $linestyle); $pdf->Line(15, 90, 195, 90, $linestyle); $pdf->Line(15, 120, 195, 120, $linestyle); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Print an image to explain cell measures $pdf->Image('tests/images/tcpdf_cell.png', 15, 160, 100, 100, 'PNG', '', '', false, 300, '', false, false, 0, false, false, false); $legend = 'LEGEND: X: cell x top-left origin (top-right for RTL) Y: cell y top-left origin (top-right for RTL) CW: cell width CH: cell height LW: line width NRL: normal line position EXT: external line position INT: internal line position ML: margin left MR: margin right MT: margin top MB: margin bottom PL: padding left PR: padding right PT: padding top PB: padding bottom TW: text width FA: font ascent FB: font baseline FD: font descent'; $pdf->SetFont('helvetica', '', 10); $pdf->setCellHeightRatio(1.25); $pdf->MultiCell(0, 0, $legend, 0, 'L', false, 1, 125, 160, true, 0, false, true, 0, 'T', false); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // CELL BORDERS // add a page $pdf->AddPage(); $pdf->SetFont('helvetica', 'B', 20); $pdf->Write(0, 'Example of borders for Cell()', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 11); // set border width $pdf->SetLineWidth(0.508); // set color for cell border $pdf->SetDrawColor(0, 128, 255); // set filling color $pdf->SetFillColor(255, 255, 128); // set cell height ratio $pdf->setCellHeightRatio(3); $pdf->Cell(30, 0, '1', 1, 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'LTRB', 'LTRB', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'LTR', 'LTR', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'TRB', 'TRB', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'LRB', 'LRB', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'LTB', 'LTB', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'LT', 'LT', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'TR', 'TR', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'RB', 'RB', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'LB', 'LB', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'LR', 'LR', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'TB', 'TB', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'L', 'L', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'T', 'T', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'R', 'R', 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(2); $pdf->Cell(30, 0, 'B', 'B', 1, 'C', 1, '', 0, false, 'T', 'C'); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ADVANCED SETTINGS FOR CELL BORDERS // add a page $pdf->AddPage(); $pdf->SetFont('helvetica', 'B', 20); $pdf->Write(0, 'Example of advanced border settings for Cell()', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFont('helvetica', '', 11); // set border width $pdf->SetLineWidth(1); // set color for cell border $pdf->SetDrawColor(0, 128, 255); // set filling color $pdf->SetFillColor(255, 255, 128); $border = array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0))); $pdf->Cell(30, 0, 'LTRB', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(5); $border = array('L' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0)), 'R' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 255)), 'T' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 255, 0)), 'B' => array('width' => 2, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 255))); $pdf->Cell(30, 0, 'LTRB', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(5); $border = array('mode' => 'ext', 'LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0))); $pdf->Cell(30, 0, 'LTRB EXT', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(5); $border = array('mode' => 'int', 'LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0))); $pdf->Cell(30, 0, 'LTRB INT', $border, 1, 'C', 1, '', 0, false, 'T', 'C'); $pdf->Ln(5); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // reset pointer to the last page $pdf->lastPage(); // --------------------------------------------------------- $this->comparePdfs($pdf); }
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; } }
$pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', '', 12); // add a page $pdf->AddPage(); $txt = 'You can set the transparency of PDF objects using the setAlpha() method.'; $pdf->Write(0, $txt, '', 0, '', true, 0, false, false, 0); /* * setAlpha() gives transparency support. You can set the * alpha channel from 0 (fully transparent) to 1 (fully * opaque). It applies to all elements (text, drawings, * images). */ $pdf->SetLineWidth(2); // draw opaque red square $pdf->SetFillColor(255, 0, 0); $pdf->SetDrawColor(127, 0, 0); $pdf->Rect(30, 40, 60, 60, 'DF'); // set alpha to semi-transparency $pdf->SetAlpha(0.5); // draw green square $pdf->SetFillColor(0, 255, 0); $pdf->SetDrawColor(0, 127, 0); $pdf->Rect(50, 60, 60, 60, 'DF'); // draw blue square $pdf->SetFillColor(0, 0, 255); $pdf->SetDrawColor(0, 0, 127); $pdf->Rect(70, 80, 60, 60, 'DF'); // draw jpeg image
public function display($arraydata, $y_axis = 0, $fielddata = false, $maxheight = 0) { $this->Rotate($arraydata["rotation"]); if ($arraydata["rotation"] != "") { if ($arraydata["rotation"] == "Left") { $w = $arraydata["width"]; $arraydata["width"] = $arraydata["height"]; $arraydata["height"] = $w; $this->pdf->SetXY($this->pdf->GetX() - $arraydata["width"], $this->pdf->GetY()); } elseif ($arraydata["rotation"] == "Right") { $w = $arraydata["width"]; $arraydata["width"] = $arraydata["height"]; $arraydata["height"] = $w; $this->pdf->SetXY($this->pdf->GetX(), $this->pdf->GetY() - $arraydata["height"]); } elseif ($arraydata["rotation"] == "UpsideDown") { //soverflow"=>$stretchoverflow,"poverflow" $arraydata["soverflow"] = true; $arraydata["poverflow"] = true; // $w=$arraydata["width"]; // $arraydata["width"]=$arraydata["height"]; //$arraydata["height"]=$w; $this->pdf->SetXY($this->pdf->GetX() - $arraydata["width"], $this->pdf->GetY() - $arraydata["height"]); } } if ($arraydata["type"] == "SetFont") { $arraydata["font"] = strtolower($arraydata["font"]); $fontfile = $this->fontdir . '/' . $arraydata["font"] . '.php'; if (file_exists($fontfile) || $this->bypassnofont == false) { $fontfile = $this->fontdir . '/' . $arraydata["font"] . '.php'; $this->pdf->SetFont($arraydata["font"], $arraydata["fontstyle"], $arraydata["fontsize"], $fontfile); } else { $arraydata["font"] = "freeserif"; if ($arraydata["fontstyle"] == "") { $this->pdf->SetFont('freeserif', $arraydata["fontstyle"], $arraydata["fontsize"], $this->fontdir . '/freeserif.php'); } elseif ($arraydata["fontstyle"] == "B") { $this->pdf->SetFont('freeserifb', $arraydata["fontstyle"], $arraydata["fontsize"], $this->fontdir . '/freeserifb.php'); } elseif ($arraydata["fontstyle"] == "I") { $this->pdf->SetFont('freeserifi', $arraydata["fontstyle"], $arraydata["fontsize"], $this->fontdir . '/freeserifi.php'); } elseif ($arraydata["fontstyle"] == "BI") { $this->pdf->SetFont('freeserifbi', $arraydata["fontstyle"], $arraydata["fontsize"], $this->fontdir . '/freeserifbi.php'); } elseif ($arraydata["fontstyle"] == "BIU") { $this->pdf->SetFont('freeserifbi', "BIU", $arraydata["fontsize"], $this->fontdir . '/freeserifbi.php'); } elseif ($arraydata["fontstyle"] == "U") { $this->pdf->SetFont('freeserif', "U", $arraydata["fontsize"], $this->fontdir . '/freeserif.php'); } elseif ($arraydata["fontstyle"] == "BU") { $this->pdf->SetFont('freeserifb', "U", $arraydata["fontsize"], $this->fontdir . '/freeserifb.php'); } elseif ($arraydata["fontstyle"] == "IU") { $this->pdf->SetFont('freeserifi', "IU", $arraydata["fontsize"], $this->fontdir . '/freeserifbi.php'); } } } elseif ($arraydata["type"] == "subreport") { return $this->runSubReport($arraydata, $y_axis); } elseif ($arraydata["type"] == "MultiCell") { if ($fielddata == false) { $this->checkoverflow($arraydata, $this->updatePageNo($arraydata["txt"]), '', $maxheight); } elseif ($fielddata == true) { //$this->checkoverflow($arraydata,$this->updatePageNo($this->analyse_expression($arraydata["txt"],$arraydata["isPrintRepeatedValues"] )),$maxheight); $this->checkoverflow($arraydata, $this->updatePageNo($this->analyse_expression($arraydata["txt"], isset($arraydata["isPrintRepeatedValues"]) ? $arraydata["isPrintRepeatedValues"] : null)), $maxheight); } } elseif ($arraydata["type"] == "SetXY") { $this->pdf->SetXY($arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis); } elseif ($arraydata["type"] == "Cell") { // print_r($arraydata); // echo "<br/>"; $this->pdf->Cell($arraydata["width"], $arraydata["height"], $this->updatePageNo($arraydata["txt"]), $arraydata["border"], $arraydata["ln"], $arraydata["align"], $arraydata["fill"], $arraydata["link"] . "", 0, true, "T", $arraydata["valign"]); } elseif ($arraydata["type"] == "Rect") { if ($arraydata['mode'] == 'Transparent') { $style = ''; } else { $style = 'FD'; } // $this->pdf->SetLineStyle($arraydata['border']); $this->pdf->Rect($arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], $style, $arraydata['border'], $arraydata['fillcolor']); } elseif ($arraydata["type"] == "RoundedRect") { if ($arraydata['mode'] == 'Transparent') { $style = ''; } else { $style = 'FD'; } // // $this->pdf->SetLineStyle($arraydata['border']); $this->pdf->RoundedRect($arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], $arraydata["radius"], '1111', $style, $arraydata['border'], $arraydata['fillcolor']); } elseif ($arraydata["type"] == "Ellipse") { //$this->pdf->SetLineStyle($arraydata['border']); $this->pdf->Ellipse($arraydata["x"] + $arraydata["width"] / 2 + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis + $arraydata["height"] / 2, $arraydata["width"] / 2, $arraydata["height"] / 2, 0, 0, 360, 'FD', $arraydata['border'], $arraydata['fillcolor']); } elseif ($arraydata["type"] == "Image") { //echo $arraydata["path"]; $path = $this->analyse_expression($arraydata["path"]); $imgtype = substr($path, -3); $arraydata["link"] = $arraydata["link"] . ""; if ($imgtype == 'jpg' || right($path, 3) == 'jpg' || right($path, 4) == 'jpeg') { $imgtype = "JPEG"; } elseif ($imgtype == 'png' || $imgtype == 'PNG') { $imgtype = "PNG"; } //echo $path; if (file_exists($this->imagesPath . $path) || $this->left($path, 4) == 'http') { //$path="/Applications/XAMPP/xamppfiles/simbiz/modules/simantz/images/modulepic.jpg"; // $path="/simbiz/images/pendingno.png"; if ($arraydata["link"] == "") { $this->pdf->Image($this->imagesPath . $path, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], $imgtype, $arraydata["link"]); } else { // if($arraydata['linktarget']=='Blank' && strpos($_SERVER['HTTP_USER_AGENT'],"Safari")!==false && strpos($_SERVER['HTTP_USER_AGENT'],"Chrome")==false){ // $href="javascript:window.open('".$arraydata["link"]."');"; // $imagehtml='<A href="'.$href.'"><img src="'.$path.'" '. // 'width="'. $arraydata["width"] .'" height="'.$arraydata["height"].'" ></A>'; // $this->pdf->writeHTMLCell($arraydata["width"],$arraydata["height"], // $arraydata["x"]+$this->arrayPageSetting["leftMargin"],$arraydata["y"]+$y_axis,$imagehtml); // } // else $this->pdf->Image($path, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], $imgtype, $arraydata["link"]); } } elseif ($this->left($path, 22) == "data:image/jpeg;base64") { $imgtype = "JPEG"; $img = str_replace('data:image/jpeg;base64,', '', $path); $imgdata = base64_decode($img); $this->pdf->Image('@' . $imgdata, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], '', $arraydata["link"]); } elseif ($this->left($path, 22) == "data:image/png;base64,") { $imgtype = "PNG"; // $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $img = str_replace('data:image/png;base64,', '', $path); $imgdata = base64_decode($img); $this->pdf->Image('@' . $imgdata, $arraydata["x"] + $this->arrayPageSetting["leftMargin"], $arraydata["y"] + $y_axis, $arraydata["width"], $arraydata["height"], '', $arraydata["link"]); } } elseif ($arraydata["type"] == "SetTextColor") { $this->textcolor_r = $arraydata['r']; $this->textcolor_g = $arraydata['g']; $this->textcolor_b = $arraydata['b']; if ($this->hideheader == true && $this->currentband == 'pageHeader') { $this->pdf->SetTextColor(100, 33, 30); } else { $this->pdf->SetTextColor($arraydata["r"], $arraydata["g"], $arraydata["b"]); } } elseif ($arraydata["type"] == "SetDrawColor") { $this->drawcolor_r = $arraydata['r']; $this->drawcolor_g = $arraydata['g']; $this->drawcolor_b = $arraydata['b']; $this->pdf->SetDrawColor($arraydata["r"], $arraydata["g"], $arraydata["b"]); } elseif ($arraydata["type"] == "SetLineWidth") { $this->pdf->SetLineWidth($arraydata["width"]); } elseif ($arraydata["type"] == "break") { } elseif ($arraydata["type"] == "Line") { $printline = false; if ($arraydata['printWhenExpression'] == "") { $printline = true; } else { $printline = $this->analyse_expression($arraydata['printWhenExpression']); } if ($printline) { $this->pdf->Line($arraydata["x1"] + $this->arrayPageSetting["leftMargin"], $arraydata["y1"] + $y_axis, $arraydata["x2"] + $this->arrayPageSetting["leftMargin"], $arraydata["y2"] + $y_axis, $arraydata["style"]); } } elseif ($arraydata["type"] == "SetFillColor") { $this->fillcolor_r = $arraydata['r']; $this->fillcolor_g = $arraydata['g']; $this->fillcolor_b = $arraydata['b']; $this->pdf->SetFillColor($arraydata["r"], $arraydata["g"], $arraydata["b"]); } elseif ($arraydata["type"] == "lineChart") { $this->showLineChart($arraydata, $y_axis); } elseif ($arraydata["type"] == "barChart") { $this->showBarChart($arraydata, $y_axis, 'barChart'); } elseif ($arraydata["type"] == "pieChart") { $this->showPieChart($arraydata, $y_axis); } elseif ($arraydata["type"] == "stackedBarChart") { $this->showBarChart($arraydata, $y_axis, 'stackedBarChart'); } elseif ($arraydata["type"] == "stackedAreaChart") { $this->showAreaChart($arraydata, $y_axis, $arraydata["type"]); } elseif ($arraydata["type"] == "Barcode") { $this->showBarcode($arraydata, $y_axis); } elseif ($arraydata["type"] == "CrossTab") { $this->showCrossTab($arraydata, $y_axis); } }