Free Support Forum - aspose.com

QR encoding in alphanumeric only

Hi all,
I’m trying to generate QR barcodes with ‘Alphanumeric’ characters.
Is there any solution to generate QR barcode with it?

Currently I use QREncodeMode.ECI_ENCODING and ECIEncodings.US_ASCII properties.
The problem is the QR version is 15, but I want to use version 11.

This QR contains a short url address and a Base32 encoded string.
The total length is 474 characters.
It has to fit to version 11.

I don’t understand this barcode generator why wants to use version 15?
What are the correct properties for version 11?

Thanks in advance.

Ferenc Dezsényi

@deferi,

Thanks for your query.

Please see the document on different QR code versions’ capacity for your reference:
https://www.qrcode.com/en/about/version.html

Hi,

Thank you for your answer.
I have checked that documentation.
The version 11 can store 468 alphanumeric characters with ECC Level L.
The version 12 can store 535 alphanumeric characters with ECC level L.

When I’m trying to use

com.aspose.barcode.QRVersion.VERSION_12

I get a

com.aspose.barcode.BarCodeException: QR Barcode - incorrect version number

exception.

What can I do to get the version 12?

Thanks

@deferi,

I use the following sample code to get QR code version 12 image, it work fine, see the attached output barcode image for your reference:
e.g
Sample code:

// Instantiate BarcodeGenerator object
		BarcodeGenerator generator = new BarcodeGenerator(com.aspose.barcode.EncodeTypes.QR,
				"ABCDEFGHIJKLMNOPQRSTUVWXYZ");

		// Set the error level
		generator.getParameters().getBarcode().getQR().setQrErrorLevel(QRErrorLevel.LEVEL_Q);

		// Set the QR barcode version number
		generator.getParameters().getBarcode().getQR().setQrVersion(com.aspose.barcode.QRVersion.VERSION_12);

		// Save the image
		generator.save("f:\\files\\qr_version12_errorQ.png");

Could you provide your sample runnable code (same as above) to show the issue, we will check it soon.
qr_version12_errorQ.png (1.9 KB)

I write here my sample code that I use:

// Instantiate BarCodeBuilder object
BarcodeGenerator generator = new BarcodeGenerator(com.aspose.barcode.EncodeTypes.QR,“HTTP://XXX.YY/A/BB0112000011234567895100112345678020200601BBXYWIXHT2WDH66ZC5OFKK2TGTG4VPUNOI23EFT3Y7OIYTMNXBJ4LPT742G4YIZCXPLS5CVVE5ADTUFFSXZYKGMISKCVLSUXWO6VV37QFKW7VHHI2AFXHC2Z6P5VBPLHDE2NIGSOPDFAWTZPIKTWJKP4GVPCC6JIR6TJ4N33IFMO33APVP6KJUOVWXXYMDXFPSH6HMBPK7NTPDUE6KOJAC6WEDRGZZ7RMM2EQ27CAJCNQEHVCXWQ3GISP6UFTGBXBKXYE5BXUZIUGV5OD5NKYCSTRYE6LIV55B5OQ2IRC6NJSOJ6YLWVVRAVZLOBQQNGW2KXNXD7IJDZGFY36X5E64SMQK3PETGIU775CDRFMKH6M73HQQQVURX7RGYMKSYJHKOEVWSGRPNRZ2NEAIYJNBOHRU======”);

	//Disable text under QR		generator.getParameters().getBarcode().getCodeTextParameters().setLocation(CodeLocation.NONE);
	
	//Set dimension
	generator.getParameters().getBarcode().getXDimension().setMillimeters(0.2f);
	
	
	//Set Paddings
	generator.getParameters().getBarcode().getPadding().getBottom().setPixels(0f);
	generator.getParameters().getBarcode().getPadding().getLeft().setPixels(0f);
	generator.getParameters().getBarcode().getPadding().getRight().setPixels(0f);
	generator.getParameters().getBarcode().getPadding().getTop().setPixels(0f);
	
	// Set the error level
	generator.getParameters().getBarcode().getQR().setQrErrorLevel(QRErrorLevel.LEVEL_L);

generator.getParameters().getBarcode().getQR().setQrEncodeMode(QREncodeMode.ECI_ENCODING);
generator.getParameters().getBarcode().getQR().setQrECIEncoding(ECIEncodings.US_ASCII);

	generator.getParameters().getBarcode().getQR().setQrEncodeType(QREncodeType.FORCE_QR);
	
	// Set the QR barcode version number
	generator.getParameters().getBarcode().getQR().setQrVersion(com.aspose.barcode.QRVersion.VERSION_12);
	
	ByteArrayOutputStream stream = new ByteArrayOutputStream();
	
	generator.getParameters().setResolution(600);
	
	
	try {
		generator.save(stream, BarCodeImageFormat.PNG);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	finally {
		if (stream != null)
			try {
				stream.close();
			} catch (IOException e) {}
	}

When I use VERSION_15 it works.

Thanks

@deferi,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

BARCODEJAVA-918 – Exception raised while generating QR code with version 12 having characters more than 366

Ok, found problem. Curently we are encoding characters with ECI mode not to optimally. We will add changes to our encoding engine. As quick workaround you can use encoding without ECI, it must encode in max density.

Thank you very much your answer.
I’m waiting for the next version of your encoding engine code.