28require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/modules_barcode.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/barcode.lib.php';
40 public $version =
'dolibarr';
58 public function info($langs)
60 return 'TCPDF-barcode';
94 if (empty($tcpdfEncoding)) {
112 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0, $filebarcode =
'')
115 if (empty($tcpdfEncoding)) {
119 $color = array(0, 0, 0);
121 $_GET[
"code"] = $code;
122 $_GET[
"type"] = $encoding;
123 $_GET[
"readable"] = $readable;
130 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
131 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
135 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
136 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
139 dol_syslog(
"buildBarCode::TCPDF.getBarcodePNG");
140 $barcodeobj->getBarcodePNG($width, $height, $color);
158 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
160 global $conf, $langs;
163 if (empty($conf->barcode)) {
166 if (empty($conf->barcode->dir_temp)) {
167 $conf->barcode->dir_temp = DOL_DATA_ROOT.
'/barcode/temp';
171 if (!is_writable($conf->barcode->dir_temp)) {
173 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
175 $this->error =
"ErrorFailedToWriteInTempDirectory ".$conf->barcode->dir_temp;
177 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
182 if (!preg_match(
'/^\w+$/', $code) ||
dol_strlen($code) > 32) {
183 $newcode =
dol_hash($newcode,
'md5');
186 $filebarcode = $conf->barcode->dir_temp .
'/barcode_' . $newcode .
'_' . $encoding .
'.png';
189 if (empty($tcpdfEncoding)) {
193 $color = array(0, 0, 0);
195 $_GET[
"code"] = $code;
196 $_GET[
"type"] = $encoding;
197 $_GET[
"readable"] = $readable;
204 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
205 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
209 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
210 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
213 dol_syslog(
"writeBarCode::TCPDF.getBarcodePngData file=".$filebarcode);
215 $imageData = (string) $barcodeobj->getBarcodePngData($width, $height, $color);
219 if (function_exists(
'imagecreate')) {
220 $imageData = imagecreatefromstring($imageData);
222 if (imagepng($imageData, $filebarcode)) {
243 $tcpdf1dEncodingTypes = array(
265 'POSTNET' =>
'POSTNET',
266 'PLANET' =>
'PLANET',
267 'RMS4CC' =>
'RMS4CC',
270 'CODABAR' =>
'CODABAR',
271 'CODE11' =>
'CODE11',
272 'PHARMA' =>
'PHARMA',
273 'PHARMA2T' =>
'PHARMA2T'
276 $tcpdf2dEncodingTypes = array(
277 'DATAMATRIX' =>
'DATAMATRIX',
278 'PDF417' =>
'PDF417',
279 'QRCODE' =>
'QRCODE,L',
280 'QRCODE,L' =>
'QRCODE,L',
281 'QRCODE,M' =>
'QRCODE,M',
282 'QRCODE,Q' =>
'QRCODE,Q',
283 'QRCODE,H' =>
'QRCODE,H'
286 if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
288 return $tcpdf1dEncodingTypes[$dolEncodingType];
289 } elseif (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
291 return $tcpdf2dEncodingTypes[$dolEncodingType];
if(! $sortfield) if(! $sortorder) $object
Class to manage translations.
Class to generate barcode images using tcpdf barcode generator.
getTcpdfEncodingType($dolEncodingType)
get available output_modes for tcpdf class with its translated description
buildBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0, $filebarcode='')
Return an image file on the fly (no need to write on disk) with the HTTP content-type (generated by T...
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.
writeBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Save an image file on disk (with no output)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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)
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.