It is impossible that you have never noticed those bar lines that are printed on the backside of any product or product related docs. Whatever it is but for us, it’s completely unreadable until we own optical character reader machine or software that reads those data which is made up of varying the widths and spacings of parallel lines in a linear structure.

In this digital era, technology is changing rapidly with new aspects of innovation to make human life easier than it was. But for Barcode its opposite, day by day it became digital and inexpensive to generate and print that can store various information. Also, it helps a lot to eliminate the possibility of human error and also it takes less little than a second to read.

Today, we are back with a different kind of blog that helps you to automatically create a barcode of invoice ID and add it to invoice pdf In Magento 2.

First, we need to create custom extension after that for displaying our barcode in invoice PDF we need to link our custom code file.

Now we need to create invoice.php which contains our logic of generating a barcode. app\code\Vendor\Extension\Plugin\invoice.php

If you working with Magento 2.3.3 you need follow with below code,

Step 1: Add this class,

Step 2:Replace this:

With this:

Tadaa! You did it.
Now you can sit back and relax. This code will automatically generate a barcode for each invoice pdf. You can also modify this according to your need of generating a barcode for various product documents.
Lastly, hit that stars if this code worked for you.
Happy Coding!

Click to rate this post!
[Total: 18 Average: 4.3]