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

    2 Comments

  1. Vladimir
    February 10, 2016
    Reply

    Hi! I try to submit UWP app to store. I use cordova and it’s phonegap-plugin-barcodescanner. Without this plugin app successfully submitted, but if I compile appxbundle with plugin, Microsoft validation return “Can’t submit pre-compiled packa-ge”.

    What you suggest in this case?

    p.s.: This plugin uses Zxing.winmd library dependencies

  2. February 19, 2016
    Reply

    Looks like .NET Native thingy :). Look at default.rd.xml . you might have to include the types which are using reflection.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...