This project has moved. For the latest updates, please go here.

PDF417 throwing "System.ArgumentException: 'CP437' is not a supported encoding name." on WP8

Mar 20, 2014 at 8:40 AM
Edited Mar 20, 2014 at 8:42 AM
Hello,

I'm trying to create a PDF417 barcode as a WriteableBitmap in a Windows Phone 8 app.

When I try and encode the image I get the following exception:
{System.ArgumentException: 'CP437' is not a supported encoding name.
Parameter name: name
at System.Globalization.EncodingTable.internalGetCodePageFromName(String name)
at System.Globalization.EncodingTable.GetCodePageFromName(String name)
at System.Text.Encoding.GetEncoding(String name)
at ZXing.PDF417.Internal.PDF417HighLevelEncoder.getBytesForMessage(String msg)
at ZXing.PDF417.Internal.PDF417HighLevelEncoder.encodeHighLevel(String msg, Compaction compaction)
at ZXing.PDF417.Internal.PDF417.generateBarcodeLogic(String msg, Int32 errorCorrectionLevel)
at ZXing.PDF417.PDF417Writer.bitMatrixFromEncoder(PDF417 encoder, String contents, Int32 width, Int32 height, Int32 margin)
at ZXing.PDF417.PDF417Writer.encode(String contents, BarcodeFormat format, Int32 width, Int32 height, IDictionary2 hints)
at ZXing.MultiFormatWriter.encode(String contents, BarcodeFormat format, Int32 width, Int32 height, IDictionary
2 hints)
at ZXing.BarcodeWriterGeneric1.Encode(String contents)
at ZXing.BarcodeWriterGeneric
1.Write(String contents)
The method calling code is:
BarcodeWriter writer = new BarcodeWriter()
{
    Format = BarcodeFormat.PDF_417,
    Options = new EncodingOptions
    {
        Height = 200,
        Width = 450
    }
};
WriteableBitmap image = writer.Write("LYL0112627857712");
Here I think CP437 refers to the Code page 437 character set. As best as I can tell Windows Phone doesn't support this character set.

If I made the barcode content shorter the error goes away. The full barcode content is actually "LYL01126278577120121431398", which I read from a sample Walgreens card I found on the internet. Image

Any ideas on how I can get a PDF417 barcode with this content on Windows Phone?

I'm using the 0.12.0.0 build names zxing.wp8.0.

Many Thanks,
Daniel
Coordinator
Mar 20, 2014 at 8:33 PM
Next version will fall back to UTF-8 on Windows Phone. That feature is implemented since revision 88380.
Since that revision the PDF417EncodingOptions class also supports the property "CharacterSet". With that property
you can specify a different encoding.