We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to encode PDF417 with hex characters

I’m wanting to encode with strictly hex characters.

Ex: 40 0a 1e 0d

Also, Should the characters be padded or can it be entered 400a1e0d?


See the document on how to generate PDF417 Barcode Family for your complete reference.

I also used the following sample code and it works fine:
Sample code:

var hexStr = "400a1e0d"; 
var byteArray = Enumerable.Range(0, hexStr.Length / 2).Select(x => Convert.ToByte(hexStr.Substring(x * 2, 2), 16)).ToArray();
var byteArrayAsString = new String(byteArray.Select(b => (char)b).ToArray());

Aspose.BarCode.Generation.BarcodeGenerator gen = new Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.Pdf417, byteArrayAsString);

//set encode mode to Binary
gen.Parameters.Barcode.Pdf417.Pdf417CompactionMode = Aspose.BarCode.Generation.Pdf417CompactionMode.Binary;
gen.Save("e:\\test2\\Pdf417.png", Aspose.BarCode.Generation.BarCodeImageFormat.Png);

//attempt to recognize
BarCodeReader read = new BarCodeReader(gen.GenerateBarCodeImage(), DecodeType.Pdf417);
foreach (BarCodeResult result in read.ReadBarCodes())

what part of the project do I add that code to


The first three lines converts the hex chars to byte array string. The rest of code is just creating the barcode based on byte array string using Aspose.BarCode for .NET API. The last lines read the barcode text. So, you may accommodate and write your own code by yourselves accordingly for your requirements.