How to Add Barcode in PDF | PHP FPDF Tutorial #9

Опубликовано: 28 Декабрь 2017
на канале: GemaCode
22,610
162

Please read the description!
welcome to the ninth chapter of PHP FPDF tutorial series.
in this chapter i will demonstrate how to add barcode in PDF using modified PHP FPDF library.
i've already prepared the barcode class in my github repository here :
https://github.com/gemul/fpdf-barcode
there are a lot of barcode standard format but here we will use only 2 format which is EAN13, and UPC_A.
if you have any question or need the source code, feel free to ask anything in the comment section.

EDIT: i forgot to mention in the video that the integer for the barcode input should be exactly 12 digits. so if your input is less than 12 digit, you should prepend it with zeroes to make it 12 digit.
as an example, $id=123;
then you should prepend it using str_pad like:
$bcid=str_pad($id,12,"0",STR_PAD_LEFT);
then use $bcid as the barcode input. it should be 000000000123. and please notice that ean13 will add check digit at the end like 0000000001236. you can ignore that last digit(6) in your reader.

Source Code : https://bit.ly/3hYdT0F
More tutorial on this series : https://goo.gl/TNqTN4