26 require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/modules_barcode.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/barcode.lib.php';
38 public $version =
'dolibarr';
56 return 'TCPDF-barcode';
91 if (empty($tcpdfEncoding)) {
108 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
113 if (empty($tcpdfEncoding))
return -1;
115 $color = array(0, 0, 0);
117 $_GET[
"code"] = $code;
118 $_GET[
"type"] = $encoding;
119 $_GET[
"readable"] = $readable;
126 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
127 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
131 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
132 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
135 dol_syslog(
"buildBarCode::TCPDF.getBarcodePNG");
136 $barcodeobj->getBarcodePNG($width, $height, $color);
154 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
159 $file = $conf->barcode->dir_temp.
'/barcode_'.$code.
'_'.$encoding.
'.png';
162 if (empty($tcpdfEncoding))
return -1;
164 $color = array(0, 0, 0);
166 $_GET[
"code"] = $code;
167 $_GET[
"type"] = $encoding;
168 $_GET[
"readable"] = $readable;
175 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
176 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
180 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
181 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
184 dol_syslog(
"writeBarCode::TCPDF.getBarcodePngData");
185 if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
186 if (function_exists(
'imagecreate')) {
187 $imageData = imagecreatefromstring($imageData);
189 if (imagepng($imageData, $file)) {
210 $tcpdf1dEncodingTypes = array(
232 'POSTNET' =>
'POSTNET',
233 'PLANET' =>
'PLANET',
234 'RMS4CC' =>
'RMS4CC',
237 'CODABAR' =>
'CODABAR',
238 'CODE11' =>
'CODE11',
239 'PHARMA' =>
'PHARMA',
240 'PHARMA2T' =>
'PHARMA2T'
243 $tcpdf2dEncodingTypes = array(
244 'DATAMATRIX' =>
'DATAMATRIX',
245 'PDF417' =>
'PDF417',
246 'QRCODE' =>
'QRCODE,L',
247 'QRCODE,L' =>
'QRCODE,L',
248 'QRCODE,M' =>
'QRCODE,M',
249 'QRCODE,Q' =>
'QRCODE,Q',
250 'QRCODE,H' =>
'QRCODE,H'
253 if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
255 return $tcpdf1dEncodingTypes[$dolEncodingType];
256 } elseif (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
258 return $tcpdf2dEncodingTypes[$dolEncodingType];
writeBarCode($code, $encoding, $readable= 'Y', $scale=1, $nooutputiferror=0)
Save an image file on disk (with no output)
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
isEnabled()
Return if a module can be used or not.
getTcpdfEncodingType($dolEncodingType)
get available output_modes for tcpdf class wth its translated description
encodingIsSupported($encoding)
Return true if encoding is supported.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
info()
Return description of numbering model.
Class to generate barcode images using tcpdf barcode generator.
Parent class for barcode document models.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
buildBarCode($code, $encoding, $readable= 'Y', $scale=1, $nooutputiferror=0)
Return an image file on the fly (no need to write on disk)