26require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/modules_barcode.class.php';
27require_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)) {
117 $color = array(0, 0, 0);
119 $_GET[
"code"] = $code;
120 $_GET[
"type"] = $encoding;
121 $_GET[
"readable"] = $readable;
128 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
129 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
133 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
134 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
137 dol_syslog(
"buildBarCode::TCPDF.getBarcodePNG");
138 $barcodeobj->getBarcodePNG($width, $height, $color);
156 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
158 global $conf, $langs, $_GET;
161 if (!is_writable($conf->barcode->dir_temp)) {
162 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
163 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
167 $file = $conf->barcode->dir_temp .
'/barcode_' . $code .
'_' . $encoding .
'.png';
170 if (empty($tcpdfEncoding)) {
174 $color = array(0, 0, 0);
176 $_GET[
"code"] = $code;
177 $_GET[
"type"] = $encoding;
178 $_GET[
"readable"] = $readable;
185 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
186 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
190 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
191 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
194 dol_syslog(
"writeBarCode::TCPDF.getBarcodePngData");
195 if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
196 if (function_exists(
'imagecreate')) {
197 $imageData = imagecreatefromstring($imageData);
199 if (imagepng($imageData, $file)) {
220 $tcpdf1dEncodingTypes = array(
242 'POSTNET' =>
'POSTNET',
243 'PLANET' =>
'PLANET',
244 'RMS4CC' =>
'RMS4CC',
247 'CODABAR' =>
'CODABAR',
248 'CODE11' =>
'CODE11',
249 'PHARMA' =>
'PHARMA',
250 'PHARMA2T' =>
'PHARMA2T'
253 $tcpdf2dEncodingTypes = array(
254 'DATAMATRIX' =>
'DATAMATRIX',
255 'PDF417' =>
'PDF417',
256 'QRCODE' =>
'QRCODE,L',
257 'QRCODE,L' =>
'QRCODE,L',
258 'QRCODE,M' =>
'QRCODE,M',
259 'QRCODE,Q' =>
'QRCODE,Q',
260 'QRCODE,H' =>
'QRCODE,H'
263 if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
265 return $tcpdf1dEncodingTypes[$dolEncodingType];
266 } elseif (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
268 return $tcpdf2dEncodingTypes[$dolEncodingType];
Parent class for barcode document models.
Class to generate barcode images using tcpdf barcode generator.
getTcpdfEncodingType($dolEncodingType)
get available output_modes for tcpdf class wth its translated description
encodingIsSupported($encoding)
Return true if encoding is supported.
info()
Return description of numbering model.
isEnabled()
Return if a module can be used or not.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
buildBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Return an image file on the fly (no need to write on disk)
writeBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Save an image file on disk (with no output)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)