Generate QR CODE in pdf document

Hello ,

I contact you about treating QR code to generate it correctly from template into a pdf.

My first question : is it the only way to do it is to use the Product Aspose Barcode?

i want to send like this my payload :

{
“templateId”: “{{TEMPLATEID_WITH_QR_CODE}}”,
“fields”: [
{
“fieldName”: “QR_CODE_FIELD”,
“fieldValue”: “text to put in QR CODE”,
“typeCode”: “IMAGE_BASE64”
}]}
My second question : the typeCode should it be as “IMAGE_BASE64” ?

and my last question : i try to build the dependency for aspose-barcode but it’s not working :
implementation group: ‘com.aspose’, name: ‘aspose-barcode’, classifier: ‘javadoc’, version: ‘22.9’

Thanks for your help!

@MDAKNOU

Could you please clarify what specific issues you are facing when trying to build the dependency for aspose-barcode? Additionally, are you asking if the typeCode should be ‘IMAGE_BASE64’ for generating the QR code in the PDF?

For the build of dependency , the build take a lot of time without any response!
yes and i m asking if in our template the mergeField for QR_CODE should have as typeCode ‘IMAGE_BASE64’ ?

Thanks!

@MDAKNOU,

1). No, Aspose.BarCode is not the only way to generate a QR code in a PDF. You have a few options depending on your requirements:

  • Aspose.BarCode is the best one as it is specific to generate and read barcodes. Moreover, if you need advanced barcode generation and recognition features, you should use it.
  • If you are filling a template and embedding an image, you can use an external QR code generator (e.g., ZXing, QRCode.js) to create a QR code as an image and insert it into the PDF using Aspose.Words/Aspose.PDF. Moreover, see the document with example code of Aspose.Words on how to generate barcode image for display barcode field for your reference.

2). If your template expects an image in Base64 format, then "IMAGE_BASE64" should be correct. You should generate the QR code as an image (PNG/JPEG), convert it to Base64, and pass it as fieldValue accordingly.

3). Your dependency declaration is incorrect. The correct way to include Aspose.BarCode for Java in Gradle is:

implementation 'com.aspose:aspose-barcode:22.9'

or

implementation("com.aspose:aspose-barcode:22.9")

Maven.

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-barcode</artifactId>
    <version>22.9</version>
</dependency>

You should not use the classifier: 'javadoc'**, as that is meant for documentation, not the actual library.