-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW functionality for display codebar on pdf files #29623
Conversation
if (class_exists($classname)) { | ||
$module = new $classname($db); | ||
if ($module->encodingIsSupported($obj->code)) { | ||
$result = $module->writeBarCode($object->ref, $encoding); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To represent url, it is better to use a QR code, you can get it by replacing param $encoding into 'QRCODE'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, done
$sql = 'SELECT rowid, code,coder FROM '.MAIN_DB_PREFIX.'c_barcode_type'; | ||
$sql .= ' WHERE rowid='.((int) (getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY'))); | ||
$sql .= ' AND entity = 1'; | ||
$resql = $db->query($sql); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside a class, you should use $this->db instead of $db.
} | ||
|
||
if ($result > 0) { | ||
$pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not $pdf->write2DBarcode ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not $pdf->write2DBarcode ?
We want to get barcode using an intermediate image using ->writeBarCode() because ->writeBarCode() is an abstraction class that is common to different barcode generator (phpbarcode and tcpdfbarcode, and more in future if we need).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the remark because seems more complicated to make first png using TCPDF and then use image iso of using TCPDF to write barcode in pdf. For object->ref not big issue, but if it is a big QR, QR quality coud be less by the image resize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the remark because seems more complicated to make first png using TCPDF and then use image iso of using TCPDF to write barcode in pdf. For object->ref not big issue, but if it is a big QR, QR quality coud be less by the image resize.
Not the same if you use $pdf->write2DBarcode() ?
I suppose that tcpdf also generates an intermediate image of the barcode, or is it directly saved as pdf instruction ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$pdf->write2DBarcode() draws barcode pixel on pdf:
dolibarr/htdocs/includes/tecnickcom/tcpdf/tcpdf.php
Line 16071 in dc8b79e
// draw a single barcode cell |
No intermediate image involved.
$modTcpdfbarcode->writeBarCode() is more for showing barcode on screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. We should enhance this by adding a method
function pdf_barcode(&$pdf, ...)
into file pdf.lib.php
with all content inside the
if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { ... }
So we will be able to replace current code with a more opmitised version
NEW|New functionality for display qrcode if this option is checked on pdf config