当前位置: 首页>>代码示例>>PHP>>正文


PHP TCPDFBarcode::getBarcodePngData方法代码示例

本文整理汇总了PHP中TCPDFBarcode::getBarcodePngData方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDFBarcode::getBarcodePngData方法的具体用法?PHP TCPDFBarcode::getBarcodePngData怎么用?PHP TCPDFBarcode::getBarcodePngData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TCPDFBarcode的用法示例。


在下文中一共展示了TCPDFBarcode::getBarcodePngData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generatePDF

 function generatePDF($action = 'return')
 {
     if (!in_array($action, ['return', 'dump'])) {
         throw $this->exception('Please provide action as result or dump');
     }
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('xEpan ERP');
     $pdf->SetTitle($this['type'] . ' ' . $this['document_no']);
     $pdf->SetSubject($this['type'] . ' ' . $this['document_no']);
     $pdf->SetKeywords($this['type'] . ' ' . $this['document_no']);
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set font
     $pdf->SetFont('dejavusans', '', 10);
     //remove header or footer hr lines
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     // add a page
     $pdf->AddPage();
     if ($org = $this->ref('contact_id')->get('organization')) {
         $this['contact'] = $org;
         $this['contact_id'] = '';
     }
     // getting layouts from config
     $layout_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['master' => 'xepan\\base\\RichText', 'detail' => 'xepan\\base\\RichText'], 'config_key' => strtoupper($this['type']) . '_LAYOUT', 'application' => 'commerce']);
     $layout_m->tryLoadAny();
     $info_config = $layout_m['master'];
     $info_layout = $this->add('GiTemplate');
     $info_layout->loadTemplateFromString($info_config);
     $detail_config = $layout_m['detail'];
     $detail_layout = $this->add('GiTemplate');
     $detail_layout->loadTemplateFromString($detail_config);
     $new = $this->add('xepan\\commerce\\Model_QSP_Master');
     $new->addHook('afterLoad', function ($m) {
         $m['round_amount'] = abs($m['round_amount']);
     });
     $new->load($this->id);
     $view = $this->app->add('xepan\\commerce\\View_QSP', ['qsp_model' => $new, 'master_template' => $info_layout, 'detail_template' => $detail_layout, 'action' => 'pdf']);
     // $view = $this->owner->add('xepan\commerce\View_QSP',['qsp_model'=>$this]);
     if ($bar_code = $this->getBarCode()) {
         $barcodeobj = new \TCPDFBarcode($bar_code, 'C128');
         // $barcode_html = $barcodeobj->getBarcodePNG(2, 30, 'black');
         $barcode_html = $barcodeobj->getBarcodePngData(1, 20, array(0, 128, 0));
         $info_layout->trySetHtml('dispatch_barcode', '<img src="data:image/png;base64, ' . base64_encode($barcode_html) . '"/>');
     }
     $html = $view->getHTML();
     // echo "string".$html;
     // echo $html;
     // exit;
     // output the HTML content
     $pdf->writeHTML($html, false, false, true, false, '');
     // set default form properties
     $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128)));
     // reset pointer to the last page
     $pdf->lastPage();
     //Close and output PDF document
     switch ($action) {
         case 'return':
             return $pdf->Output(null, 'S');
             break;
         case 'dump':
             return $pdf->Output(null, 'I');
             exit;
             break;
     }
 }
开发者ID:xepan,项目名称:commerce,代码行数:68,代码来源:Master.php

示例2: writeBarCode

 /**
  *	Save an image file on disk (with no output)
  *
  *	@param	   string	    $code		      Value to encode
  *	@param	   string	    $encoding	      Mode of encoding
  *	@param	   string	    $readable	      Code can be read
  *	@param	   integer		$scale			  Scale (not used with this engine)
  *  @param     integer      $nooutputiferror  No output if error (not used with this engine)
  *	@return	   int			                  <0 if KO, >0 if OK
  */
 function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
 {
     global $conf, $_GET;
     dol_mkdir($conf->barcode->dir_temp);
     $file = $conf->barcode->dir_temp . '/barcode_' . $code . '_' . $encoding . '.png';
     $tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
     if (empty($tcpdfEncoding)) {
         return -1;
     }
     $color = array(0, 0, 0);
     $_GET["code"] = $code;
     $_GET["type"] = $encoding;
     $_GET["height"] = $height;
     $_GET["readable"] = $readable;
     if ($code) {
         // Load the tcpdf barcode class
         if ($this->is2d) {
             $height = 1;
             $width = 1;
             require_once TCPDF_PATH . 'tcpdf_barcodes_2d.php';
             $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
         } else {
             $height = 50;
             $width = 1;
             require_once TCPDF_PATH . 'tcpdf_barcodes_1d.php';
             $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
         }
         dol_syslog("writeBarCode::TCPDF.getBarcodePngData");
         if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
             if (function_exists('imagecreate')) {
                 $imageData = imagecreatefromstring($imageData);
             }
             if (imagepng($imageData, $file)) {
                 return 1;
             } else {
                 return -3;
             }
         } else {
             return -4;
         }
     } else {
         return -2;
     }
 }
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:54,代码来源:tcpdfbarcode.modules.php


注:本文中的TCPDFBarcode::getBarcodePngData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。