Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

(no description)

Author: Nicola Asuni
Version: 1.0.015
File Size: 349 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

TCPDF2DBarcode:: (8 methods):
  __construct()
  getBarcodeArray()
  getBarcodeSVG()
  getBarcodeSVGcode()
  getBarcodeHTML()
  getBarcodePNG()
  getBarcodePngData()
  setBarcode()


Class: TCPDF2DBarcode  - X-Ref


__construct($code, $type)   X-Ref
This is the class constructor.
Return an array representations for 2D barcodes:<ul>
<li>$arrcode['code'] code to be printed on text label</li>
<li>$arrcode['num_rows'] required number of rows</li>
<li>$arrcode['num_cols'] required number of columns</li>
<li>$arrcode['bcode'][$r][$c] value of the cell is $r row and $c column (0 = transparent, 1 = black)</li></ul>

param: $code (string) code to print
param: $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>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".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul>

getBarcodeArray()   X-Ref
Return an array representations of barcode.

return: array

getBarcodeSVG($w=3, $h=3, $color='black')   X-Ref
Send barcode as SVG image object to the standard output.

param: $w (int) Width of a single rectangle element in user units.
param: $h (int) Height of a single rectangle element in user units.
param: $color (string) Foreground color (in SVG format) for bar elements (background is transparent).

getBarcodeSVGcode($w=3, $h=3, $color='black')   X-Ref
Return a SVG string representation of barcode.

param: $w (int) Width of a single rectangle element in user units.
param: $h (int) Height of a single rectangle element in user units.
param: $color (string) Foreground color (in SVG format) for bar elements (background is transparent).
return: string SVG code.

getBarcodeHTML($w=10, $h=10, $color='black')   X-Ref
Return an HTML representation of barcode.

param: $w (int) Width of a single rectangle element in pixels.
param: $h (int) Height of a single rectangle element in pixels.
param: $color (string) Foreground color for bar elements (background is transparent).
return: string HTML code.

getBarcodePNG($w=3, $h=3, $color=array(0,0,0)   X-Ref
Send a PNG image representation of barcode (requires GD or Imagick library).

param: $w (int) Width of a single rectangle element in pixels.
param: $h (int) Height of a single rectangle element in pixels.
param: $color (array) RGB (0-255) foreground color for bar elements (background is transparent).

getBarcodePngData($w=3, $h=3, $color=array(0,0,0)   X-Ref
Return a PNG image representation of barcode (requires GD or Imagick library).

param: $w (int) Width of a single rectangle element in pixels.
param: $h (int) Height of a single rectangle element in pixels.
param: $color (array) RGB (0-255) foreground color for bar elements (background is transparent).
return: image or false in case of error.

setBarcode($code, $type)   X-Ref
Set the barcode.

param: $code (string) code to print
param: $type (string) type of barcode: <ul><li>DATAMATRIX : Datamatrix (ISO/IEC 16022)</li><li>PDF417 : PDF417 (ISO/IEC 15438:2006)</li><li>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".</li><li>QRCODE : QRcode Low error correction</li><li>QRCODE,L : QRcode Low error correction</li><li>QRCODE,M : QRcode Medium error correction</li><li>QRCODE,Q : QRcode Better error correction</li><li>QRCODE,H : QR-CODE Best error correction</li><li>RAW: raw mode - comma-separad list of array rows</li><li>RAW2: raw mode - array rows are surrounded by square parenthesis.</li><li>TEST : Test matrix</li></ul>
return: array