:
[Test]
public void Hex2Pdf417()
{
var hexStr = "fe3009333137303130323031f9200134fe300120fc2006";
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());
// encode the string as PDF417
var writer = new BarcodeWriter
{
Format = BarcodeFormat.PDF_417,
Options = new PDF417EncodingOptions
{
Height = 200,
Width = 200,
Margin = 10
}
};
var bitmap = writer.Write(byteArrayAsString);
// try to decode the PDF417
var reader = new BarcodeReader
{
Options = new DecodingOptions
{
PossibleFormats = new List<BarcodeFormat>
{
BarcodeFormat.PDF_417
},
PureBarcode = true
}
};
var result = reader.Decode(bitmap);
// make sure, the result is the same as the original hex
var resultBackToBytes = result.Text.Select(c => (byte)c).ToArray();
var resultAsHexString = String.Join("", resultBackToBytes.Select(b => b.ToString("x2")));
Assert.That(resultAsHexString, Is.EqualTo(hexStr));
}
CP850から「81」のようないくつかのHEXがエラーをスロー:検出 非符号化可能なキャラクタ(ユニコード:132) またiは復号場合バーコードここではonline-barcode-reader.inliteresearch.com、それは保存されたHEXデータが元のHEXではないことを示します。 "FE"は "5F"として保存されます。 – user3236231
いくつかの小さなエラーのため、ZXing.Netの現在のバージョン0.14ではすべての状況でコードが正しく動作しません。 – Michael
ありがとう!これは、ソースコードの最新バージョンと完全に動作しています! https://github.com/micjahn/ZXing.Net/から自己コンパイル! – user3236231