สำหรับในบทความนี้จะเป็นการแนะนำการ สร้าง Barcode รหัสแท่งมาตรฐานสําหรับการชําระเงิน (Standard Payment Barcode) ตามประกาศของธนาคารแห่งประเทศไทย
รายละเอียดเพิ่มเติมเดียวกับประกาศ
https://www.bot.or.th/Thai/PaymentSystems/StandardPS/Barcode/Pages/default.aspx
รูปแบบของ Barcode
ใช้ Barcode Type Code 128 ความยาวไม่เกิน 62 หลัก และสูงไม่น้อยกว่า 1 เซนติเมตร
ตัวอย่างรายละเอียดข้อมูลที่ต้องพิมพ์ใน Barcode มีดังนี้
สำหรับคำอธิบายรายละเอียดต่าง ๆ สามารถอ่านเพิ่มเติมได้ที่
https://www.bot.or.th/Thai/PaymentSystems/StandardPS/DocLib/Std_Barcode.pdf
ตัวอย่างการสร้าง Barcode ด้วย PHP
ในตัวอย่างนี้ใช้วิธีการสร้าง Barcode จากบทความ การสร้าง-barcodeด้วย-php
<?php
include "src/BarcodeGenerator.php";
include('src/BarcodeGeneratorPNG.php');
$code = [
"|012345678901200\n123456789012345678\n123456789012345678\n0",
"|012345678901200\n123456789012345678\n123456789012345678\n0",
];
$i = 1;
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
foreach($code as $barcode){
echo '<p style="font-size:14px;">';
echo '<img width="380" height="35" src="data:image/png;base64,' . base64_encode($generatorPNG->getBarcode($barcode, $generatorPNG::TYPE_CODE_128)) . '">';
echo '<br>';
echo $barcode."</p>";
}
?>
ผลการทำงาน
ขอขอบคุณข้อมูลจาก