ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
TCPDF2DBarcode Class Reference
+ Collaboration diagram for TCPDF2DBarcode:

Public Member Functions

 __construct ($code, $type)
 This is the class constructor.
 getBarcodeArray ()
 Return an array representations of barcode.
 setBarcode ($code, $type)
 Set the barcode.

Protected Attributes

 $barcode_array = false

Detailed Description

Definition at line 55 of file 2dbarcodes.php.

Constructor & Destructor Documentation

TCPDF2DBarcode::__construct (   $code,
  $type 
)

This is the class constructor.

Return an array representations for 2D barcodes:

  • $arrcode['code'] code to be printed on text label
  • $arrcode['num_rows'] required number of rows
  • $arrcode['num_cols'] required number of columns
  • $arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)
Parameters
string$codecode to print
string$typetype of barcode:
  • RAW: raw mode - comma-separad list of array rows
  • RAW2: raw mode - array rows are surrounded by square parenthesis.
  • QRCODE : QR-CODE Low error correction
  • QRCODE,L : QR-CODE Low error correction
  • QRCODE,M : QR-CODE Medium error correction
  • QRCODE,Q : QR-CODE Better error correction
  • QRCODE,H : QR-CODE Best error correction
  • PDF417 : PDF417 (ISO/IEC 15438:2006)
  • PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".

Definition at line 73 of file 2dbarcodes.php.

References $type, and setBarcode().

{
$this->setBarcode($code, $type);
}

+ Here is the call graph for this function:

Member Function Documentation

TCPDF2DBarcode::getBarcodeArray ( )

Return an array representations of barcode.

Returns
array

Definition at line 81 of file 2dbarcodes.php.

References $barcode_array.

{
}
TCPDF2DBarcode::setBarcode (   $code,
  $type 
)

Set the barcode.

Parameters
string$codecode to print
string$typetype of barcode:
  • RAW: raw mode - comma-separad list of array rows
  • RAW2: raw mode - array rows are surrounded by square parenthesis.
  • QRCODE : QR-CODE Low error correction
  • QRCODE,L : QR-CODE Low error correction
  • QRCODE,M : QR-CODE Medium error correction
  • QRCODE,Q : QR-CODE Better error correction
  • QRCODE,H : QR-CODE Best error correction
  • PDF417 : PDF417 (ISO/IEC 15438:2006)
  • PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6 : PDF417 with parameters: a = aspect ratio (width/height); e = error correction level (0-8); t = total number of macro segments; s = macro segment index (0-99998); f = file ID; o0 = File Name (text); o1 = Segment Count (numeric); o2 = Time Stamp (numeric); o3 = Sender (text); o4 = Addressee (text); o5 = File Size (numeric); o6 = Checksum (numeric). NOTES: Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional. To use a comma character ',' on text options, replace it with the character 255: "\xff".
Returns
array

Definition at line 91 of file 2dbarcodes.php.

References $type.

Referenced by __construct().

{
$mode = explode(',', $type);
$qrtype = strtoupper($mode[0]);
switch ($qrtype) {
case 'QRCODE': { // QR-CODE
require_once(dirname(__FILE__).'/qrcode.php');
if (!isset($mode[1]) OR (!in_array($mode[1],array('L','M','Q','H')))) {
$mode[1] = 'L'; // Ddefault: Low error correction
}
$qrcode = new QRcode($code, strtoupper($mode[1]));
$this->barcode_array = $qrcode->getBarcodeArray();
break;
}
case 'PDF417': { // PDF417 (ISO/IEC 15438:2006)
require_once(dirname(__FILE__).'/pdf417.php');
if (!isset($mode[1]) OR ($mode[1] === '')) {
$aspectratio = 2; // default aspect ratio (width / height)
} else {
$aspectratio = floatval($mode[1]);
}
if (!isset($mode[2]) OR ($mode[2] === '')) {
$ecl = -1; // default error correction level (auto)
} else {
$ecl = intval($mode[2]);
}
// set macro block
$macro = array();
if (isset($mode[3]) AND ($mode[3] !== '') AND isset($mode[4]) AND ($mode[4] !== '') AND isset($mode[5]) AND ($mode[5] !== '')) {
$macro['segment_total'] = intval($mode[3]);
$macro['segment_index'] = intval($mode[4]);
$macro['file_id'] = strtr($mode[5], "\xff", ',');
for ($i = 0; $i < 7; ++$i) {
$o = $i + 6;
if (isset($mode[$o]) AND ($mode[$o] !== '')) {
// add option
$macro['option_'.$i] = strtr($mode[$o], "\xff", ',');
}
}
}
$qrcode = new PDF417($code, $ecl, $aspectratio, $macro);
$this->barcode_array = $qrcode->getBarcodeArray();
break;
}
case 'RAW':
case 'RAW2': { // RAW MODE
// remove spaces
$code = preg_replace('/[\s]*/si', '', $code);
if (strlen($code) < 3) {
break;
}
if ($qrtype == 'RAW') {
// comma-separated rows
$rows = explode(',', $code);
} else { // RAW2
// rows enclosed in square parentheses
$code = substr($code, 1, -1);
$rows = explode('][', $code);
}
$this->barcode_array['num_rows'] = count($rows);
$this->barcode_array['num_cols'] = strlen($rows[0]);
$this->barcode_array['bcode'] = array();
foreach ($rows as $r) {
$this->barcode_array['bcode'][] = str_split($r, 1);
}
break;
}
case 'TEST': { // TEST MODE
$this->barcode_array['num_rows'] = 5;
$this->barcode_array['num_cols'] = 15;
$this->barcode_array['bcode'] = array(
array(1,1,1,0,1,1,1,0,1,1,1,0,1,1,1),
array(0,1,0,0,1,0,0,0,1,0,0,0,0,1,0),
array(0,1,0,0,1,1,0,0,1,1,1,0,0,1,0),
array(0,1,0,0,1,0,0,0,0,0,1,0,0,1,0),
array(0,1,0,0,1,1,1,0,1,1,1,0,0,1,0));
break;
}
default: {
$this->barcode_array = false;
}
}
}

+ Here is the caller graph for this function:

Field Documentation

TCPDF2DBarcode::$barcode_array = false
protected

Definition at line 61 of file 2dbarcodes.php.

Referenced by getBarcodeArray().


The documentation for this class was generated from the following file: