Hello Magento Friends,

Welcome to Magento 2 “How to” blog series by MageComp. Today’s solution is for, How to Create QR Code of invoice ID and add it to Magento 2 invoice PDF. The previous blog was about How to Get Quote Information using REST API in Magento 2.

Introduction:

QR Code is an abbreviation for Quick Response Code. QR codes are easily readable by mobile devices. Default Magento QR code functionality is not provided in the invoice pdf. You need to install the QRcode library in your Magento: “composer require aferrandini/phpqrcode”. To display the QR code in the invoice PDF follow the below steps. 

Let’s learn How to Create QR Code of invoice ID and add it to Magento 2 Invoice PDF.

Steps to Create QR Code of invoice ID and add it to Magento 2 invoice PDF:

Step 1: First, we need to create a “di.xml” file inside our extension at the below path

app\code\Vendor\Extension\adminhtmletc\di.xml

And add the code as below:

Step 2: After that, we need to create an  “Invoice.php” file inside the below folder path of the extension

app\code\Vendor\Extension\Model\Order\Pdf\Invoice.php

And add the below code:

That’s it. The invoice PDF will now display the QR Code as shown in the following image.

qr code invoice pdf magento 2

Conclusion:

Hence, with the help of the above steps, you can successfully Create QR Code of invoice ID and add it to Magento 2 invoice PDF. For queries and difficulties mention in the comment part. Allow your customers to download invoice PDF whenever require from the store frontend by integrating Download Invoice PDF Extension for Magento 2.

You would also like to refer to our related article – How to create Barcode of invoice ID and add it to Magento 2 invoice PDF.

If you found the article useful, share it with your Magento companions. I will be back with another article, till then stay in touch with us. 

Happy Coding!

Click to rate this post!
[Total: 9 Average: 4.6]