Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php barcode generator

//In this PHP code, the tc-lib-barcode library autoload file is included at the beginning. Then the form data is received by using the POST request data array. The MFG and EXP dates are converted into a timestamp.

//Then, the product MRP and MFG/EXP timestamps are bundled into a string format. This formatted product data will be passed to the getBarcodeObj. This function will return barcode object based on the type specified.

<?php
if (! empty($_POST["generate"])) {
    require ('tc-lib-barcode/vendor/autoload.php');
    $barcode = new ComTecnickBarcodeBarcode();
    $targetPath = "barcode/";
    
    if (! is_dir($targetPath)) {
        mkdir($targetPath, 0777, true);
    }
    $MRP = $_POST["mrp"];
    $MFGDate = strtotime($_POST["mfg_date"]);
    $EXPDate = strtotime($_POST["exp_date"]);
    $productData = "098{$MRP}10{$MFGDate}55{$EXPDate}";
    $barcode = new ComTecnickBarcodeBarcode();
    $bobj = $barcode->getBarcodeObj('C128C', "{$productData}", 450, 70, 'black', array(
        0,
        0,
        0,
        0
    ));
    
    $imageData = $bobj->getPngData();
    $timestamp = time();
    
    file_put_contents($targetPath . $timestamp . '.png', $imageData);
    ?>
<div class="result-heading">Output:</div>
<img src="<?php echo $targetPath . $timestamp ; ?>.png">
<?php
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: page.php woocommerce 
Php :: php access class variable 
Php :: laravel set timezone dynamically 
Php :: php RFC3339 
Php :: php code add text on existing pdf file 
Php :: symfony twig variable 
Php :: laravel relationship retrieve data 
Php :: php thread safe or not thread safe windows 
Php :: php replace url parameter value 
Php :: SIMPLE linked list in php 
Php :: where is view folder in laravel 
Php :: php pass a function as a parameter 
Php :: echo foreach 
Php :: cpanel composer update kill 
Php :: id type laravel 
Php :: str_contains — Determine if a string contains a given substring 
Php :: logout all users laravel 8 
Php :: packagist carbon 
Php :: whats the difference between using date function and DATETime in php 
Php :: php ternary operator good example 
Php :: laravel collection all 
Php :: laravel.log" could not be opened in append mode 
Php :: laravel debugbar ServiceProvider to the providers 
Php :: PHP Custom Time Ago Function 
Php :: laravel dingo api response 
Php :: Remove the additional notes area from the WooCommerce checkout 
Php :: PHP strnatcasecmp — Case insensitive string comparisons using a "natural order" algorithm 
Php :: membuat aplikasi dengan array dalam bahasa pemrograman PHP 
Php :: Array unpacking support for string-keyed arrays - PHP 8.1 
Php :: SQLSTATE[42S02]: Base table or view not found: 1146 Table many to many in laravel 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =