Barcode generation

Need help.
Trying to add barcodes to PDF templates (for example invoice, quotation, etc ). Add barcode from https://barcode.tec-it.com/ . But this is not good solution (one time number of barcodes are more than 50-100).
Find https://github.com/picqer/php-barcode-generator . It was easy to embed to simple php page, but not in SuiteCRM.
Who can explain step-by step how to embed barcode to pdf template?
Thank you

SuiteCRM 7.11.18, PHP 7.3

1 Like

No one uses barcodes in Suitecrm?

Hi @anyketua,
to add barcodes to PDF templates in SuiteCRM, I would try the following steps:

  1. Download the PHP Barcode Generator library from GitHub (GitHub - picqer/php-barcode-generator: Barcode generator in PHP that is easy to use, non-bloated and framework independent.).
  2. Extract the downloaded archive and upload the “src” folder to your SuiteCRM instance in the custom directory. For example, you can upload it to custom/php-barcode-generator.
  3. Create a new PDF template or edit an existing one in SuiteCRM. You can do this by going to the “PDF Templates” section in the admin panel.
  4. In the PDF template editor, add a placeholder where you want to insert the barcode. You can do this by clicking on the “Add Field” button and selecting “Text” from the dropdown menu.
  5. In the “Text” field settings, enter a unique name for the field and select the “Variable” option for the “Type” field.
  6. In the “Variable Name” field, enter a unique name for the variable, such as “barcode”.
  7. Save the PDF template.
  8. Open the PHP file that generates the PDF, which is usually located in the custom/modules//views directory.
  9. Add the following code to the PHP file to generate the barcode:

phpCopy code

// Load the PHP Barcode Generator library
require_once 'custom/php-barcode-generator/autoload.php';

// Generate the barcode image
$barcode = new Picqer\Barcode\BarcodeGeneratorPNG();
$barcodeImage = $barcode->getBarcode('<barcode value>', $barcode::TYPE_CODE_128);

// Add the barcode image to the PDF
$pdf->Image('@'.$barcodeImage);

Replace <barcode value> with the value you want to encode in the barcode.

  1. Save the PHP file.
  2. Run a Quick Repair and Rebuild in SuiteCRM to ensure that the new files are recognized.

After completing these steps, the PDF template should include a barcode image based on the value you specified.