Example #1
11
 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;
 }
Example #2
0
 function renderPDF($document = '', $staticData = array())
 {
     // LOADING OF HELPER FILES (extended TCPDF library), LISTENING TO Phoca PDF Plugins
     $option = JRequest::getCmd('option');
     $t = JString::ucfirst(str_replace('com_', '', $option));
     // Used abstract class of Phoca PDF (e.g. in VM)
     if ($option == 'com_phocapdf') {
         $type = JRequest::getCmd('type');
         switch ($type) {
             case 'invoice':
             case 'receipt':
             case 'deliverynote':
                 $option = 'com_virtuemart';
                 break;
         }
     }
     // Static Data - if the function is called as static with defined parameters
     // and the pdf is not rendered as document
     if (isset($staticData['option']) && $staticData['option'] != '') {
         $option = $staticData['option'];
         $pdfFileName = $staticData['filename'];
         $t = '';
     }
     // Define - must be called before calling the plugin (because plugin includes definition file of tcpdf,
     // so it must be defined before
     if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
         define('K_TCPDF_EXTERNAL_CONFIG', true);
     }
     if (!defined('K_PATH_MAIN')) {
         define("K_PATH_MAIN", JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_phocapdf' . DS . 'assets' . DS . 'tcpdf');
     }
     if (!defined('K_PATH_URL')) {
         define("K_PATH_URL", JPATH_BASE);
     }
     // URL path
     if (!defined('K_PATH_FONTS')) {
         define("K_PATH_FONTS", JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_phocapdf' . DS . 'fonts' . DS);
     }
     if (!defined('K_PATH_CACHE')) {
         define("K_PATH_CACHE", K_PATH_MAIN . DS . 'cache' . DS);
     }
     // Cache directory path
     $urlPath = JURI::base(true) . '/administrator/components/com_phocapdf/assets/tcpdf/';
     // Cache URL path
     if (!defined('K_PATH_URL_CACHE')) {
         define("K_PATH_URL_CACHE", $urlPath . 'cache/');
     }
     if (!defined('K_PATH_IMAGES')) {
         define("K_PATH_IMAGES", K_PATH_MAIN . DS . 'images' . DS);
     }
     // Images path
     if (!defined('K_BLANK_IMAGE')) {
         define("K_BLANK_IMAGE", K_PATH_IMAGES . DS . "_blank.png");
     }
     // Blank image path
     if (!defined('K_CELL_HEIGHT_RATIO')) {
         define("K_CELL_HEIGHT_RATIO", 1.25);
     }
     // Cell height ratio
     if (!defined('K_TITLE_MAGNIFICATION')) {
         define("K_TITLE_MAGNIFICATION", 1.3);
     }
     // Magnification scale for titles
     if (!defined('K_SMALL_RATIO')) {
         define("K_SMALL_RATIO", 2 / 3);
     }
     // Reduction scale for small font
     if (!defined('HEAD_MAGNIFICATION')) {
         define("HEAD_MAGNIFICATION", 1.1);
     }
     // Magnication scale for head
     if (!defined('PDF_PAGE_FORMAT')) {
         define('PDF_PAGE_FORMAT', 'A4');
     }
     // page format
     if (!defined('PDF_PAGE_ORIENTATION')) {
         define('PDF_PAGE_ORIENTATION', 'P');
     }
     // page orientation (P=portrait, L=landscape)
     if (!defined('PDF_CREATOR')) {
         define('PDF_CREATOR', 'Phoca PDF');
     }
     // document creator
     if (!defined('PDF_AUTHOR')) {
         define('PDF_AUTHOR', 'Phoca PDF');
     }
     // document author
     if (!defined('PDF_HEADER_TITLE')) {
         define('PDF_HEADER_TITLE', 'Phoca PDF');
     }
     // header title
     if (!defined('PDF_HEADER_STRING')) {
         define('PDF_HEADER_STRING', "Phoca PDF");
     }
     // header description string
     //define('PDF_HEADER_LOGO', 'tcpdf_logo.jpg');// image logo
     //define('PDF_HEADER_LOGO_WIDTH', 30);// header logo image width [mm]
     if (!defined('PDF_UNIT')) {
         define('PDF_UNIT', 'mm');
     }
     // document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]
     if (!defined('PDF_header_margin')) {
         define('PDF_header_margin', 10);
     }
     // header margin
     if (!defined('PDF_footer_margin')) {
         define('PDF_footer_margin', 10);
     }
     // footer margin
     if (!defined('PDF_MARGIN_TOP')) {
         define('PDF_MARGIN_TOP', 33);
     }
     // top margin
     if (!defined('PDF_MARGIN_BOTTOM')) {
         define('PDF_MARGIN_BOTTOM', 25);
     }
     // bottom margin
     if (!defined('PDF_MARGIN_LEFT')) {
         define('PDF_MARGIN_LEFT', 15);
     }
     // left margin
     if (!defined('PDF_MARGIN_RIGHT')) {
         define('PDF_MARGIN_RIGHT', 15);
     }
     // right margin
     if (!defined('PDF_FONT_NAME_MAIN')) {
         define('PDF_FONT_NAME_MAIN', 'helvetica');
     }
     // main font name
     if (!defined('PDF_FONT_SIZE_MAIN')) {
         define('PDF_FONT_SIZE_MAIN', 10);
     }
     // main font size
     if (!defined('PDF_FONT_NAME_DATA')) {
         define('PDF_FONT_NAME_DATA', 'helvetica');
     }
     // data font name
     if (!defined('PDF_FONT_SIZE_DATA')) {
         define('PDF_FONT_SIZE_DATA', 8);
     }
     // data font size
     if (!defined('PDF_IMAGE_SCALE_RATIO')) {
         define('PDF_IMAGE_SCALE_RATIO', 4);
     }
     // Ratio used to scale the images
     if (!defined('K_TCPDF_CALLS_IN_HTML')) {
         define('K_TCPDF_CALLS_IN_HTML', true);
     }
     switch ($option) {
         case 'com_content':
             $content = new JObject();
             // Get info from Phoca PDF Content Plugin
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('system');
             $results = $dispatcher->trigger('onBeforeCreatePDFContent', array(&$content));
             if (JFile::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_phocapdf' . DS . 'helpers' . DS . 'phocapdfcontenttcpdf.php')) {
                 require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_phocapdf' . DS . 'helpers' . DS . 'phocapdfcontenttcpdf.php';
                 $pdf = new PhocaPDFContentTCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
             } else {
                 return JError::raiseError('PDF ERROR', 'Document cannot be created - Loading of Phoca PDF library (Content) failed');
             }
             break;
         case 'com_phocamenu':
             // Get info from Phoca PDF Restaurant Menu Plugin
             $content = new JObject();
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('phocapdf');
             $results = $dispatcher->trigger('onBeforeCreatePDFRestaurantMenu', array(&$content));
             if (JFile::exists(JPATH_SITE . DS . 'plugins' . DS . 'phocapdf' . DS . 'restaurantmenu.php')) {
                 require_once JPATH_SITE . DS . 'plugins' . DS . 'phocapdf' . DS . 'restaurantmenu.php';
                 $pdf = new PhocaPDFRestaurantMenuTCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
             } else {
                 return JError::raiseError('PDF ERROR', 'Document cannot be created - Loading of Phoca PDF Plugin (Restaurant Menu) failed');
             }
             break;
         case 'com_virtuemart':
             // Get info from Phoca PDF VirtueMart Plugin
             $content = new JObject();
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('phocapdf');
             $results = $dispatcher->trigger('onBeforeCreatePDFVirtueMart', array(&$content, $staticData));
             if (JFile::exists(JPATH_SITE . DS . 'plugins' . DS . 'phocapdf' . DS . 'virtuemart.php')) {
                 require_once JPATH_SITE . DS . 'plugins' . DS . 'phocapdf' . DS . 'virtuemart.php';
                 $pdf = new PhocaPDFVirtueMartTCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
                 $pdf->setStaticData($staticData);
             } else {
                 return JError::raiseError('PDF ERROR', 'Document cannot be created - Loading of Phoca PDF Plugin (VirtueMart) failed');
             }
             break;
         default:
             require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_phocapdf' . DS . 'helpers' . DS . 'phocapdf.php';
             require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_phocapdf' . DS . 'assets' . DS . 'tcpdf' . DS . 'tcpdf.php';
             $content = new JObject();
             // Get info from Phoca PDF Content Plugin
             $dispatcher =& JDispatcher::getInstance();
             JPluginHelper::importPlugin('system');
             $results = $dispatcher->trigger('onBeforeCreatePDF' . $t, array(&$content));
             $pdf = new TCPDF($content->page_orientation, 'mm', $content->page_format, true, 'UTF-8', $content->use_cache);
             break;
             break;
     }
     //krumo("exit");exit;
     $pdf->SetMargins($content->margin_left, $content->margin_top, $content->margin_right);
     $pdf->SetAutoPageBreak(TRUE, $content->margin_bottom);
     $pdf->setCellHeightRatio($content->site_cell_height);
     $pdf->setFont($content->font_type);
     $siteFontColor = $pdf->convertHTMLColorToDec($content->site_font_color);
     $pdf->SetTextColor($siteFontColor['R'], $siteFontColor['G'], $siteFontColor['B']);
     //$pdf->setPageFormat($content->page_format, $content->page_orientation);
     $pdf->SetHeaderMargin($content->header_margin);
     $pdf->SetFooterMargin($content->footer_margin);
     $pdf->setImageScale($content->image_scale);
     // PDF Metadata
     $pdf->SetCreator(PDF_CREATOR);
     // Content
     switch ($option) {
         default:
             $results = $dispatcher->trigger('onBeforeDisplayPDF' . $t, array(&$pdf, &$content, &$this));
             break;
         case 'com_content':
             $results = $dispatcher->trigger('onBeforeDisplayPDFContent', array(&$pdf, &$content, &$document));
             break;
         case 'com_phocamenu':
             $results = $dispatcher->trigger('onBeforeDisplayPDFRestaurantMenu', array(&$pdf, &$content, &$document));
             break;
         case 'com_virtuemart':
             $results = $dispatcher->trigger('onBeforeDisplayPDFVirtueMart', array(&$pdf, &$content, &$document, $staticData));
             break;
     }
     if (isset($staticData['file']) && $staticData['file'] != '') {
         $pdf->Output($staticData['file'], 'F');
         return true;
     }
     // Called from administrator area (administrator calls frontend view, but it still administrator area)
     $adminView = JRequest::getVar('admin', 0, '', 'int');
     if ($adminView == 1) {
         $content->pdf_destination = 'S';
     }
     if ($content->pdf_destination == 'D' || $content->pdf_destination == 'I') {
         $pdf->Output($content->pdf_name, $content->pdf_destination);
         return true;
     }
     $data = $pdf->Output($content->pdf_name, $content->pdf_destination);
     return $data;
 }
Example #3
0
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');
$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');
Example #4
0
 $pdf->SetTitle($json->today);
 $pdf->SetSubject($json->today);
 $pdf->SetKeywords($json->today);
 // 设置页眉和页脚信息
 $pdf->SetHeaderData('', 0, '今日|' . $json->today, 'today.exformation.com.cn');
 $pdf->setFooterData('today.exformation.com.cn');
 // 设置页眉和页脚字体
 $pdf->setHeaderFont(array('droidsansfallback', '', '10'));
 $pdf->setFooterFont(array('helvetica', '', '8'));
 // 设置默认等宽字体
 $pdf->SetDefaultMonospacedFont('courier');
 // 设置间距
 $pdf->SetMargins(15, 21, 15);
 $pdf->SetHeaderMargin(5);
 $pdf->SetFooterMargin(10);
 $pdf->setCellHeightRatio(0.7);
 // 设置分页
 $pdf->SetAutoPageBreak(TRUE, 25);
 // set image scale factor
 $pdf->setImageScale(1.25);
 // set default font subsetting mode
 $pdf->setFontSubsetting(true);
 //设置字体
 $pdf->SetFont('droidsansfallback', '', 12);
 $pdf->AddPage();
 $content = renderHead($json);
 $content .= '<br/>';
 foreach ($json->tasks as $item) {
     $content = $content . render($item->title, $item->completedAt, $item->duration, $item->memo);
 }
 $pdf->writeHTML($content);
Example #5
0
 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;
     }
 }
Example #6
0
 public function actionGenCodeCard($request_type)
 {
     // Validate settings
     if (!Yii::app()->user->checkAccess("UserAdmin")) {
         $this->redirect(array('view', 'id' => $model->id));
     }
     $code_card = Yii::app()->getModule('user')->codeCard;
     if (empty($code_card['host']) || empty($code_card['apy_key']) || empty($code_card['crypt_key'])) {
         $this->redirect(array('view', 'id' => $model->id));
     }
     $model = $this->loadModel();
     $profile = $model->profile;
     $error = '';
     if ($request_type == 'validate_code') {
         if (empty($_POST['code']) || empty($_POST['session_id'])) {
             $this->redirect(array('view', 'id' => $model->id));
         }
         $add_data = $_POST['code'];
         $session_id = $_POST['session_id'];
     } else {
         $add_data = $model->id;
         $session_id = '';
     }
     $request = array('request_type' => $request_type, 'user_id' => Yii::app()->user->getId(), 'add_data' => $add_data, 'session_id' => $session_id);
     $reply = array('error' => '');
     CodeCard::request($request, $reply);
     if ($reply['error']) {
         $error = UserModule::t($reply['error']);
     } elseif ($reply['reply_type'] == 'code_card') {
         // Savec codeCard expire date
         $profile->setAttribute('code_card_expire_date', $reply['add_data']['expire_date']);
         $profile->save();
         // Save codeCard as PDF
         $pdf = new TCPDF('L', PDF_UNIT, 'BUSINESS_CARD_ES', true, 'UTF-8', false);
         //Basic setup
         $pdf->setPrintHeader(false);
         $pdf->setPrintFooter(false);
         // set default monospaced font
         $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
         // set margins
         $pdf->SetMargins(0, 2, 4, true);
         $pdf->SetHeaderMargin(0);
         $pdf->SetFooterMargin(0);
         // set font
         $pdf->SetFont('helvetica', '', 8);
         $pdf->setCellHeightRatio(1.1);
         // add a page
         $pdf->AddPage();
         $html = $this->renderPartial('codeCard', array('reply' => $reply), true);
         //echo $html;
         //exit;
         // output the HTML content
         $pdf->writeHTML($html, false);
         // reset pointer to the last page
         $pdf->lastPage();
         $pdf->Output('CodeCard.pdf', 'D');
         exit;
     }
     if ($reply['reply_type'] == 'validate_code') {
         $view = 'validate_code';
     } else {
         $view = 'codeCard_empty';
     }
     if (Yii::app()->getModule('user')->view) {
         $alt_view = Yii::app()->getModule('user')->view . '.admin.' . $view;
         if (is_readable(Yii::getPathOfAlias($alt_view) . '.php')) {
             $view = $alt_view;
             $this->layout = Yii::app()->getModule('user')->layout;
         }
     }
     $this->render($view, array('model' => $model, 'reply' => $reply, 'error' => $error));
 }
Example #7
0
//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');
$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');
Example #8
0
 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;
 }
	/**
	 * Display the view
	 *
	 * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
	 *
	 * @return  mixed  A string if successful, otherwise a Error object.
	 *
	 * @since       1.7.2
	 */
	public function display($tpl = null)
	{
		$app    = JFactory::getApplication();
		$params = JComponentHelper::getParams('com_churchdirectory');

		// Get some data from the models
		$state    = $this->get('State');
		$items    = $this->get('Items');
		$category = $this->get('Category');

		// Check whether category access level allows access.
		$user   = JFactory::getUser();
		$groups = $user->getAuthorisedViewLevels();

		if (!in_array($category->access, $groups))
		{
			$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');

			return false;
		}

		if ($items == false)
		{
			$app->enqueueMessage(JText::_('COM_CHURCHDIRECTOY_ERROR_DIRECTORY_NOT_FOUND'), 'error');

			return false;
		}

		$this->count    = count($items);
		$this->subcount = count($items);
		$children       = $this->get('Children');
		$pagination     = $this->get('Pagination');
		$this->loadHelper('render');
		$renderHelper = new ChurchDirectoryRenderHelper;
		$this->span   = $renderHelper->rowWidth($params->get('rows_per_page'));
		JLoader::register('DirectoryHeaderHelper', JPATH_SITE . '/components/com_churchdirectory/helpers/directoryheader.php');
		$this->header = new DirectoryHeaderHelper;
		$this->header->setPages($params);

		// Prepare the data.
		// Compute the contact slug.
		for ($i = 0, $n = $this->count; $i < $n; $i++)
		{
			$item       = & $items[$i];
			$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
			$temp       = new Joomla\Registry\Registry;
			$temp->loadString($item->params);
			$item->params = clone $params;
			$item->params->merge($temp);

			if ($item->params->get('show_email', 0) == 1)
			{
				$item->email_to = trim($item->email_to);

				if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to))
				{
					$item->email_to = '<a href="mailto::' . $item->email_to . '">' . $item->email_to . '</a>';
				}
				else
				{
					$item->email_to = '';
				}
			}

			if ($item->params->get('dr_show_street_address') || $item->params->get('dr_show_suburb')
				|| $item->params->get('dr_show_state') || $item->params->get('dr_show_postcode') || $item->params->get('dr_show_country'))
			{
				$params->set('address_check', 1);
			}
			else
			{
				$params->set('address_check', 0);
			}

			if ($item->params->get('dr_show_email') || $item->params->get('dr_show_telephone')
				|| $item->params->get('dr_show_fax') || $item->params->get('dr_show_mobile')
				|| $item->params->get('dr_show_webpage') || $item->params->get('dr_show_spouse')
				|| $item->params->get('dr_show_children'))
			{
				$params->set('other_check', 1);
			}
			else
			{
				$params->set('other_check', 0);
			}

			switch ($params->get('dr_churchdirectory_icons'))
			{
				case 1 :
					// Text
					$params->set('marker_address', JText::_('COM_CHURCHDIRECTORY_ADDRESS') . ": ");
					$params->set('marker_email', JText::_('JGLOBAL_EMAIL') . ": ");
					$params->set('marker_telephone', JText::_('COM_CHURCHDIRECTORY_TELEPHONE') . ": ");
					$params->set('marker_fax', JText::_('COM_CHURCHDIRECTORY_FAX') . ": ");
					$params->set('marker_mobile', JText::_('COM_CHURCHDIRECTORY_MOBILE') . ": ");
					$params->set('marker_misc', JText::_('COM_CHURCHDIRECTORY_OTHER_INFORMATION') . ": ");
					$params->set('marker_class', 'jicons-text');
					break;

				case 2 :
					// None
					$params->set('marker_address', '');
					$params->set('marker_email', '');
					$params->set('marker_telephone', '');
					$params->set('marker_mobile', '');
					$params->set('marker_fax', '');
					$params->set('marker_misc', '');
					$params->set('marker_class', 'jicons-none');
					break;

				default :
					// Icons
					$image1 = JHtml::_('image', 'contacts/' . $params->get('icon_address', 'con_address.png'), JText::_('COM_CHURCHDIRECTORY_ADDRESS') .
							": ", null, true
					);
					$image2 = JHtml::_('image', 'contacts/' . $params->get('icon_email', 'emailButton.png'), JText::_('JGLOBAL_EMAIL') . ": ", null, true);
					$image3 = JHtml::_('image', 'contacts/' . $params->get('icon_telephone', 'con_tel.png'), JText::_('COM_CHURCHDIRECTORY_TELEPHONE') .
							": ", null, true
					);
					$image4 = JHtml::_('image', 'contacts/' . $params->get('icon_fax', 'con_fax.png'), JText::_('COM_CHURCHDIRECTORY_FAX') . ": ", null, true);
					$image5 = JHtml::_('image', 'contacts/' . $params->get('icon_misc', 'con_info.png'), JText::_('COM_CHURCHDIRECTORY_OTHER_INFORMATION') .
							": ", null, true
					);
					$image6 = JHtml::_('image', 'contacts/' . $params->get('icon_mobile', 'con_mobile.png'), JText::_('COM_CHURCHDIRECTORY_MOBILE') .
							": ", null, true
					);

					$params->set('marker_address', $image1);
					$params->set('marker_email', $image2);
					$params->set('marker_telephone', $image3);
					$params->set('marker_fax', $image4);
					$params->set('marker_misc', $image5);
					$params->set('marker_mobile', $image6);
					$params->set('marker_class', 'jicons-icons');
					break;
			}
		}

		$params->set('prepare_content', '0');

		// Setup the category parameters.
		$cparams          = $category->getParams();
		$category->params = clone $params;
		$category->params->merge($cparams);
		$children = [$category->id => $children];
		$maxLevel = $params->get('maxLevel', -1);
		$items    = $renderHelper->groupit(['items' => & $items, 'field' => 'lname']);

		if (0)
		{
			foreach ($items as $s1)
			{
				$items[$s1] = $renderHelper->groupit(['items' => $items[$s1], 'field' => 'suburb']);
			}
		}

		$this->renderHelper = $renderHelper;
		$this->maxLevel     = & $maxLevel;
		$this->state        = & $state;
		$this->items        = $items;
		$this->category     = & $category;
		$this->children     = & $children;
		$this->params       = & $params;
		$this->pagination   = & $pagination;

		// Escape strings for HTML output
		$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));

		$menus = $app->getMenu();
		$title = 'directory_prent_out';

		// Because the application sets a default page title,
		// we need to get it from the menu item itself
		$menu = $menus->getActive();

		// Clean the output buffer
		@ob_end_clean();

		// Create new PDF document
		$this->pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

		// Set document information
		$this->pdf->SetCreator(PDF_CREATOR);
		$this->pdf->SetAuthor('NFSDA Church');
		$this->pdf->SetTitle($this->params->get('page_title', ''));
		$this->pdf->SetSubject('Church Directory');
		$this->pdf->SetKeywords('Directory, PDF, Members');

		// Set default header data
		$this->pdf->setHeaderData(
			$params->get('pdf_logo'),
			$params->get('pdf_logo_width'),
			$this->params->get('page_heading'),
			$params->get('pdf_header_string')
		);

		// Remove default header/footer
		$this->pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
		$this->pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

		// Set default monospaced font
		$this->pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

		// Set margins
		$this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
		$this->pdf->setHeaderMargin(PDF_MARGIN_HEADER);
		$this->pdf->setFooterMargin(PDF_MARGIN_FOOTER);

		// Set auto page breaks
		$this->pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);

		$this->pdf->setCellHeightRatio(1.25);

		// Set image scale factor
		$this->pdf->setImageScale(2.5);

		// ---------------------------------------------------------

		// Set font
		$this->pdf->SetFont('times', 'BI', 8, '', 'false');

		// Set some text to print
		$html = $this->loadTemplate($tpl);

		$jweb  = new JApplicationWeb;
		$jweb->clearHeaders();

		// Close and output PDF document
		$this->pdf->Output($title . '.pdf', 'I');

		return null;
	}
Example #10
0
    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);
    }
Example #11
-1
 /**
  * @param string $content
  * @param float|string $x
  * @param float|string $y
  * @param float|string $width
  * @param float|string $height
  * @param array $attrs {
  *      @option string "font_family" required
  *      @option string[] "font_style" required
  *      @option float|string "font_size" required
  *      @option string "color" required
  *      @option string "overflow" optional default is "trunecate"
  *      @option boolean "single_row" optional default is false
  *      @option string "align" optional default is "left"
  *      @option string "valign" optional default is "top"
  *      @option string "letter_spacing" optional default is 0
  *      @option string "line_height" optional default is {@see self::$pdf_default_line_height}
  * }
  * @see http://www.tcpdf.org/doc/code/classTCPDF.html
  */
 public function drawTextBox($content, $x, $y, $width, $height, array $attrs = array())
 {
     $styles = $this->buildTextBoxStyles($height, $attrs);
     $this->setFontStyles($styles);
     $this->pdf->setFontSpacing($styles['letter_spacing']);
     $this->pdf->setCellHeightRatio($styles['line_height']);
     $overflow = $styles['overflow'];
     $font_family = $attrs['font_family'];
     $font_styles = $attrs['font_style'];
     $color = $styles['color'];
     $emulating = $this->startStyleEmulation($font_family, $font_styles, $color);
     $this->pdf->MultiCell($width, $height, $content, 0, $styles['align'], false, 1, $x, $y, true, 0, false, true, $overflow['max_height'], $styles['valign'], $overflow['fit_cell']);
     if ($emulating) {
         $this->resetStyleEmulation();
     }
 }