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';
53 public function info($langs)
55 return 'TCPDF-barcode';
89 if (empty($tcpdfEncoding)) {
106 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
111 if (empty($tcpdfEncoding)) {
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)
156 global $conf, $langs, $_GET;
159 if (!is_writable($conf->barcode->dir_temp)) {
160 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
161 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
165 $file = $conf->barcode->dir_temp .
'/barcode_' . $code .
'_' . $encoding .
'.png';
168 if (empty($tcpdfEncoding)) {
172 $color = array(0, 0, 0);
174 $_GET[
"code"] = $code;
175 $_GET[
"type"] = $encoding;
176 $_GET[
"readable"] = $readable;
183 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
184 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
188 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
189 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
192 dol_syslog(
"writeBarCode::TCPDF.getBarcodePngData");
193 if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
194 if (function_exists(
'imagecreate')) {
195 $imageData = imagecreatefromstring($imageData);
197 if (imagepng($imageData, $file)) {
218 $tcpdf1dEncodingTypes = array(
240 'POSTNET' =>
'POSTNET',
241 'PLANET' =>
'PLANET',
242 'RMS4CC' =>
'RMS4CC',
245 'CODABAR' =>
'CODABAR',
246 'CODE11' =>
'CODE11',
247 'PHARMA' =>
'PHARMA',
248 'PHARMA2T' =>
'PHARMA2T'
251 $tcpdf2dEncodingTypes = array(
252 'DATAMATRIX' =>
'DATAMATRIX',
253 'PDF417' =>
'PDF417',
254 'QRCODE' =>
'QRCODE,L',
255 'QRCODE,L' =>
'QRCODE,L',
256 'QRCODE,M' =>
'QRCODE,M',
257 'QRCODE,Q' =>
'QRCODE,Q',
258 'QRCODE,H' =>
'QRCODE,H'
261 if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
263 return $tcpdf1dEncodingTypes[$dolEncodingType];
264 } elseif (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
266 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.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
info($langs)
Return description of numbering model.
isEnabled()
Return if a module can be used or not.
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)