2D Barcodes and "national characters" problem
Posted: Fri May 03, 2013 10:01 am
Hi, when I try to generate PDF417, QR or DataMatrix and in the "data" I have special national characters, specifically " ť ď ľ ň ě š č ř ž ý á í é ó ú ", the Barcodes sometimes do get generated, but most of the times return an error / the generated output is not readable.
The other issue is, when I the QRGetSize function, for this input it gives me version == 5, but when I use this version, I get the "BarcodeQrEncoderInvalidVersionBarcode" error, so I had to use the value 0 for the generating function. When the input is purely english characters, everything works fine and I can use the version I get from GetSize function.
I attach an output PDF, where I try to generate all three of them using " ť ď ľ ň ě š č ř ž ý á í é ó ú " as the input data.
The code for reading barcodes is the same as you use in your samples, like I said, it works on english characters without any problems. I also attached the output file, using the same code, when I use only english letters. Here is the output I get from my ReadBarcode function on the good output:
*Edit - I just found out, that in case of DataMatrix and PDF417, the codes seem to be fine, just the way I try to read them seems to have problems - might be just different encoding of the string and I might be able to fix this, so, that doesn't seem to be an issue now, just a problem with the way my solution is writen. However, if you can point me towards how to find out what encoding is used and how to convert it to right input, that would be great.
However, the QR code generation is not working, which you can clearly see in the output file.
The other issue is, when I the QRGetSize function, for this input it gives me version == 5, but when I use this version, I get the "BarcodeQrEncoderInvalidVersionBarcode" error, so I had to use the value 0 for the generating function. When the input is purely english characters, everything works fine and I can use the version I get from GetSize function.
I attach an output PDF, where I try to generate all three of them using " ť ď ľ ň ě š č ř ž ý á í é ó ú " as the input data.
Code: Select all
if (type == Barcode_Subtype.Barcode_QR)
{
int version = 0;
int size = Imaging.BarcodeQRGetSize(Data, BarcodeQREncodingMode.BarcodeQREncodingModeUndefined, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelH, ref version, 4, 4);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(size, size);
Image_ID = Imaging.CreateGdPictureImageFromBitmap(bitmap);
status = Imaging.BarcodeQRWrite(Image_ID, Data, BarcodeQREncodingMode.BarcodeQREncodingModeUndefined, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelH, 0, 4, 4, 0, 0, 0, System.Drawing.Color.Black, System.Drawing.Color.White);
}
else if (type == Barcode_Subtype.Barcode_PDF417)
{
int width = 0;
int height = 0;
int cols = 0;
int rows = 0;
BarcodePDF417ErrorCorrectionLevel corr_level = BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto;
status = Imaging.BarcodePDF417GetSize(Data, BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined, ref corr_level, ref rows, ref cols, 4, 4, 15, ref width, ref height);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height);
Image_ID = Imaging.CreateGdPictureImageFromBitmap(bitmap);
status = Imaging.DrawFilledRectangle(Image_ID, 0, 0, width, height, System.Drawing.Color.White, false);
status = Imaging.BarcodePDF417Write(Image_ID, Data, BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined, corr_level, rows, cols, 4, 4, 15, 0, 0, 0, System.Drawing.Color.Black, System.Drawing.Color.White);
}
else if (type == Barcode_Subtype.Barcode_DataMatrix)
{
BarcodeDataMatrixVersion version = BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto;
int width = 0;
int height = 0;
status = Imaging.BarcodeDataMatrixGetSize(Data, BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeUndefined, ref version, 4, 4, ref width, ref height);
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height);
Image_ID = Imaging.CreateGdPictureImageFromBitmap(bitmap);
status = Imaging.DrawFilledRectangle(Image_ID, 0, 0, width, height, System.Drawing.Color.White, false);
status = Imaging.BarcodeDataMatrixWrite(Image_ID, Data, BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeUndefined, ref version, 4, 4, 0, 0, 0, System.Drawing.Color.Black, System.Drawing.Color.White);
}
Code: Select all
BarCode #1 - Barcode1DReaderEAN13:
8594160390009:
BarCode #2 - PDF417:
This is text in the PDF417:
BarCode #3 - QR Code:
This is text in the QR code:
BarCode #4 - Data Matrix:
This is text in the Data Matrix:
However, the QR code generation is not working, which you can clearly see in the output file.