This project has moved and is read-only. For the latest updates, please go here.

The easiest way to encode text/

Jan 13, 2014 at 8:03 PM
Hi.

I'm prepearing an application using WPF. One of its feature is to print label with id barcodes for each product added to the database each day. I decided to generate PDF with 8 barcodes/page in order to allow user print labels simply. But the problem is, I have no idea how to encode text into barcode (code128). Is there any easy solution to do that?
Jan 13, 2014 at 9:40 PM
You should take a look at the WinForms demo. You can get it from the download section in the source code archive or you make a working copy from the source code repository.
The WinForms demo shows how you can encode a text to a barcode. Small snippet:
var writer = new BarcodeWriter
{
   Format = BarcodeFormat.CODE_128
};
var bitmap = writer.Write("your text here");
Use the bitmap with your PDF generation code.
Jan 13, 2014 at 10:27 PM
The problem is, I get an error message:
"The type 'System.Drawing.Bitmap' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken..."
I've tried to resolve that, but it was not possible. Then I tried to add System.Drawing.Bitmap namespace but there is not "Bitmap" in System.Drawing.
Jan 14, 2014 at 8:42 PM
You have to use the assembly zxing.presentation.dll besides the zxing.dll.
Unfortunately the current version of that does only contains a BarcodeReader for WPF.
I committed an enhancement which adds a BarcodeWriter for WPF.
The WPFDemo shows now how it can be used.

If you send me a private message over codeplex I can send you a new binary of zxing.presentation.dll for testing.
Or you build your own version of the dll with the current source from the repository.

Alternatively you can use the class BarcodeWriterSvg. That gives you a SVG image instead of a bitmap.