Return a PNG image representation of barcode (requires GD or Imagick library).
public getBarcodePNG ( $w = 2, $h = 30, $color = [0, 0, 0] ) : image | ||
$w | (int) Width of a single bar element in pixels. | |
$h | (int) Height of a single bar element in pixels. | |
$color | (array) RGB (0-255) foreground color for bar elements (background is transparent). | |
Résultat | image | or false in case of error. |
// // TCPDF is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with TCPDF. If not, see <http://www.gnu.org/licenses/>. // // See LICENSE.TXT file for more information. // ------------------------------------------------------------------- // // Description : Example for tcpdf_barcodes_2d.php class // //============================================================+ /** * @file * Example for tcpdf_barcodes_2d.php class * @package com.tecnick.tcpdf * @author Nicola Asuni * @version 1.0.000 */ // include 1D barcode class (search for installation path) require_once dirname(__FILE__) . '/tcpdf_barcodes_1d_include.php'; // set the barcode content and type $barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128'); // output the barcode as PNG image $barcodeobj->getBarcodePNG(2, 30, array(0, 0, 0)); //============================================================+ // END OF FILE //============================================================+
if ($numRow == 0) { $qty = $_POST['qty'][$key]; $sqlGetInbound = $db->get_where('inbound_po', 'inbound_id = ' . $key); $rsGetInbound = $sqlGetInbound->row_array(); $data = array('pallet_id' => $updateID, 'po_id' => $rsGetInbound['po_id'], 'inbound_key' => $rsGetInbound['inbound_id'], 'supplier_id' => $rsGetInbound['po_supplier'], 'qty' => $qty, 'create_time' => _DATE_TIME_, 'user_id' => $user_id); $db->insert('inbound_pallet_item', $data); } else { if ($numRow == 1) { $qty = $_POST['qty'][$key] + $rsRow['qty']; $data = array('qty' => $qty); $db->update('inbound_pallet_item', $data, 'id =' . $rsRow['id']); } } $barcode = str_pad($updateID, 10, "0", STR_PAD_LEFT); $barcodeobj = new TCPDFBarcode($barcode, 'C128'); $showBarcode = $barcodeobj->getBarcodePNG(2, 30, array(0, 0, 0), $updateID); $back['barcode'] = ' <span class="detailBarcode" style="text-align: center; line-height:40px;font-size: 16px;float:right;"> <span class="barcodeImg" style="margin-left:10px; margin-top:10px;"> <img class="imgBarcode" src="data:image/png;base64,' . $showBarcode . '" style="" /> </span> </span> '; //echo $db->last_query(); } $back['actionID'] = $updateID; echo json_encode($back); } else { if ($_POST['method'] == 'manage_pallet_success') { $palletID = $_POST['palletID']; $db->edit('inbound_pallet', array('pallet_status' => 1, 'confirm_time' => _DATE_TIME_), array('pallet_id' => $palletID));
/** * Return an image file on the fly (no need to write on disk) * * @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 buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $_GET; $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 = 3; $width = 3; 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("buildBarCode::TCPDF.getBarcodePNG"); $barcodeobj->getBarcodePNG($width, $height, $color); return 1; } else { return -2; } }
</td> <td> <button onclick="$.managePallet(<?php echo $arr['pallet_id']; ?> )">จัดการ</button> </td> </tr> <div id="barcode<?php echo $arr['pallet_id']; ?> " style="display: none;"> <?php $barcode = str_pad($arr['pallet_id'], 10, "0", STR_PAD_LEFT); $barcodeobj = new TCPDFBarcode($barcode, 'C128'); $showBarcode = $barcodeobj->getBarcodePNG(2, 30, array(0, 0, 0), $arr['pallet_id']); echo ' <span class="detailBarcode" style="text-align: center; line-height:40px;font-size: 16px;float:right;"> <span class="barcodeImg" style="margin-left:10px; margin-top:10px;"> <img class="imgBarcode" src="data:image/png;base64,' . $showBarcode . '" style="" /> </span> </span> '; ?> </div> <?php } ?> </tbody> </table> </div>