dolibarr 20.0.0
barcode.lib.php File Reference

Set of functions used for barcode generation (internal lib, also code 'phpbarcode') More...

Go to the source code of this file.

Functions

if(getDolGlobalString( 'GENBARCODE_LOCATION')) barcode_print ($code, $encoding="ANY", $scale=2, $mode="png", $filebarcode='')
 Print barcode.
 
 barcode_encode ($code, $encoding)
 Encodes $code with $encoding using genbarcode OR built-in encoder if you don't have genbarcode only EAN-13/ISBN or UPC is possible.
 
 barcode_gen_ean_sum ($ean)
 Calculate EAN sum.
 
 barcode_gen_ean_bars ($ean)
 Generate EAN bars.
 
 barcode_encode_ean ($ean, $encoding="EAN-13")
 Encode EAN.
 
 barcode_encode_upc ($upc, $encoding="UPC")
 Encode UPC.
 
 barcode_encode_genbarcode ($code, $encoding)
 Encode result of genbarcode command.
 
 barcode_outimage ($text, $bars, $scale=1, $mode="png", $total_y=0, $space=[], $filebarcode='')
 Output image onto standard output, or onto disk if $filebarcode is defined.
 
 isAValidEAN13 ($ean)
 Check if EAN13 code is valid.
 

Detailed Description

Set of functions used for barcode generation (internal lib, also code 'phpbarcode')

Definition in file barcode.lib.php.

Function Documentation

◆ barcode_encode()

barcode_encode ( $code,
$encoding )

Encodes $code with $encoding using genbarcode OR built-in encoder if you don't have genbarcode only EAN-13/ISBN or UPC is possible.

You can use the following encodings (when you have genbarcode): ANY choose best-fit (default) EAN 8 or 13 EAN-Code UPC 12-digit EAN ISBN isbn numbers (still EAN-13) 39 code 39 128 code 128 (a,b,c: autoselection) 128C code 128 (compact form for digits) 128B code 128, full printable ascii I25 interleaved 2 of 5 (only digits) 128RAW Raw code 128 (by Leonid A. Broukhis) CBR Codabar (by Leonid A. Broukhis) MSI MSI (by Leonid A. Broukhis) PLS Plessey (by Leonid A. Broukhis)

Parameters
string$codeCode
string$encodingEncoding
Returns
array{encoding:string,bars:string,text:string}|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)

Definition at line 132 of file barcode.lib.php.

References barcode_encode_ean(), barcode_encode_genbarcode(), barcode_encode_upc(), dol_escape_htmltag(), and dol_syslog().

Referenced by barcode_print().

◆ barcode_encode_ean()

barcode_encode_ean ( $ean,
$encoding = "EAN-13" )

Encode EAN.

Parameters
string$eanCode
string$encodingEncoding
Returns
array{encoding:string,bars:string,text:string,error:string}|array{text:string,error:string} array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info, 'error': error message if error)

Definition at line 234 of file barcode.lib.php.

References barcode_gen_ean_bars(), and barcode_gen_ean_sum().

Referenced by barcode_encode().

◆ barcode_encode_genbarcode()

barcode_encode_genbarcode ( $code,
$encoding )

Encode result of genbarcode command.

Parameters
string$codeCode
string$encodingEncoding
Returns
array{encoding:string,bars:string,text:string}|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)

Definition at line 340 of file barcode.lib.php.

References dol_string_nospecial(), and dol_syslog().

Referenced by barcode_encode().

◆ barcode_encode_upc()

barcode_encode_upc ( $upc,
$encoding = "UPC" )

Encode UPC.

Parameters
string$upcCode
string$encodingEncoding
Returns
array{encoding:string,bars:string,text:string,error:string}|array{text:string,error:string} array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info, 'error': error message if error)

Definition at line 290 of file barcode.lib.php.

References barcode_gen_ean_bars(), and barcode_gen_ean_sum().

Referenced by barcode_encode().

◆ barcode_gen_ean_bars()

barcode_gen_ean_bars ( $ean)

Generate EAN bars.

Parameters
string$eanEAN to encode
Returns
string Encoded EAN

Definition at line 204 of file barcode.lib.php.

Referenced by barcode_encode_ean(), and barcode_encode_upc().

◆ barcode_gen_ean_sum()

barcode_gen_ean_sum ( $ean)

Calculate EAN sum.

Parameters
string$eanEAN to encode
Returns
int<0,9> EAN Sum

Definition at line 180 of file barcode.lib.php.

Referenced by barcode_encode_ean(), barcode_encode_upc(), mod_barcode_product_standard\getNextValue(), and mod_barcode_thirdparty_standard\getNextValue().

◆ barcode_outimage()

barcode_outimage ( $text,
$bars,
$scale = 1,
$mode = "png",
$total_y = 0,
$space = [],
$filebarcode = '' )

Output image onto standard output, or onto disk if $filebarcode is defined.

Parameters
string$textthe text-line (<position>:<font-size>:<character> ...)
string$barswhere to place the bars (<space-width><bar-width><space-width><bar-width>...)
int<1,max>$scale scale factor ( 1 < scale < unlimited (scale 50 will produce 5400x300 pixels when using EAN-13!!!))
string$modeMime 'png', 'gif', 'jpg', 'jpeg' (default='png') or file disk if empty.
int$total_ythe total height of the image ( default: scale * 60 )
array{}|array{top:int,bottom:int,left:int,right:int}$space default: $space[top] = 2 * $scale; $space[bottom]= 2 * $scale; $space[left] = 2 * $scale; $space[right] = 2 * $scale;
string$filebarcodeFilename to store barcode image file
Returns
void

Definition at line 416 of file barcode.lib.php.

References top_httphead().

Referenced by barcode_print().

◆ barcode_print()

if(getDolGlobalString('GENBARCODE_LOCATION')) barcode_print ( $code,
$encoding = "ANY",
$scale = 2,
$mode = "png",
$filebarcode = '' )

Print barcode.

Parameters
string$codeCode
string$encodingEncoding ('EAN13', 'ISBN', 'C128', 'UPC', 'CBR', 'QRCODE', 'DATAMATRIX', 'ANY'...)
int<1,max>$scale Scale
string$mode'png', 'gif', 'jpg', 'jpeg' ...
string$filebarcodeFilename to store barcode image file if defined
Returns
array{encoding:string,bars:string,text:string}|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message

Definition at line 83 of file barcode.lib.php.

References barcode_encode(), barcode_outimage(), and dol_syslog().

Referenced by modPhpbarcode\buildBarCode().

◆ isAValidEAN13()

isAValidEAN13 ( $ean)

Check if EAN13 code is valid.

Parameters
string$eanCode
Returns
bool

Definition at line 525 of file barcode.lib.php.