Generating Barcode in your Windows Phone 8 App using ZXing.Net Library

ZXing.Net is a library that supports reading and generating of barcodes within the Windows Phone 8 App . The ZXing.Net Library supports the barcode formats like UPC-A, EAN-8, EAN-13, Code 39, Code 128, ITF, Codabar, Plessey, MSI, QR Code, PDF-417, Aztec, Data Matrix etc.

This blog post will demonstrate how to generate barcode using ZXing.Net library in windows phone.

Generating Barcode in your Windows Phone 8 App using ZXing.Net Library

To generate the barcode in your Windows Phone 8 App using ZXing.Net Library, follow the below steps.

1. Download the ZXing.Net Library from ZXing.Net Library CodePlex page

2. Extract the downloaded zip file and add the reference of the ZXing.Net Library (zxing.wp8.0.dll) found in the WP8.0 of the extracted folder to your Windows Phone Project.

3. The ZXing.Net Library provides the BarcodeWriter class defined in the ZXing namespace which lets you to generate the barcode. The developers can also define the format of the barcode via the “Format” property of the BarcodeWriter. The Write method of the BarcodeWriter is used to define the string to be encoded for the barcode. Below is code sample demonstrating the generation of the barcode and showing it in the Image control (barcodeImg).

//Generate Barcode in Windows Phone 8

BarcodeWriter BarcodeData = new BarcodeWriter();

BarcodeData.Format = BarcodeFormat.QR_CODE;

BarcodeData.Options.Height = 500;

BarcodeData.Options.Width = 500;

BarcodeData.Options.Margin = 1;

var barcodeImage = BarcodeData.Write("This is @isenthil and Welcome to MobileOSGeek.com");

barcodeImg.Source = barcodeImage;

Note: Include the namespaces ZXing and ZXing.Rendering.

4. Launch the Application and invoke the above code via event handler (button click etc.) and you should see the barcode generated and displayed in the image control.

Generating Barcode in your Windows Phone 8 App using ZXing.Net Library

5. Let’s try to scan this generated barcode on the emulator from a Windows Phone device. In your Windows Phone 8, tap the search hardware button to open the Bing search and then tap the Vision Icon in the Application Bar and then bring the focus to the generated barcode which should identify the string within the barcode as shown below.

Generating Barcode in your Windows Phone 8 App using ZXing.Net Library

Generating Barcode in your Windows Phone 8 App using ZXing.Net Library

 

Download the Generating Barcode in your Windows Phone 8 App using ZXing.Net Library sample source code here

3 Comments

  1. Vladimir February 10, 2016 Reply
    • Senthil Kumar B February 19, 2016 Reply

Leave a Reply