We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can we read barcode using Syncfusion

Thread ID:

Created:

Updated:

Platform:

Replies:

127029 Oct 21,2016 10:41 AM Jul 28,2017 08:25 AM UWP 3
loading
Tags: SfBarcode
Swati Das
Asked On October 21, 2016 10:41 AM

Hi,

We have a requirement where we need to read the bar code from a PDF file. Can we do it using Syncfusion? If yes, then could you please provide me the code snippet for that ?

I have come across examples for generating the bar code, but none for reading it. So kindly help me with this.

Thanks in advance.

Regards,
Swati

Chinnu Muniyappan [Syncfusion]
Replied On October 26, 2016 05:26 AM

Hi Swati, 
 
Thank you for contacting Syncfusion support. 
 
Currently we don’t have support for reading barcodes in Universal Windows platform, however we have created a workaround sample for achieving your requirement. Here we have using Syncfusion.SfPdfViewerControl to export PDF page to image and scan the image to Zxing barcode scanner. Please refer the below code snippet and sample for more details. 
 
            
            //Initialize PDF viewer control 
            SfPdfViewerControl control = new SfPdfViewerControl(); 
 
            //Load the PDF document 
            await control.LoadDocumentAsync(docStream); 
 
            //Export the page as image 
            Stream imgStream = await control.ExportAsImage(0); 
            
            imgStream.Position = 0; 
 
            //Get the image RGB data 
            var BitmapImageDecoder = await BitmapDecoder.CreateAsync(imgStream.AsRandomAccessStream()); 
 
            PixelDataProvider provider = await BitmapImageDecoder.GetPixelDataAsync().AsTask().ConfigureAwait(false); 
            var imageData = provider.DetachPixelData(); 
 
            //initialize the ZXing barcode reader 
            ZXing.BarcodeReader reader = new ZXing.BarcodeReader(); 
 
            //Reader the barcode 
            ZXing.Result[] results = reader.DecodeMultiple(imageData, (int)BitmapImageDecoder.PixelWidth, (int)BitmapImageDecoder.PixelHeight, ZXing.RGBLuminanceSource.BitmapFormat.Unknown); 
 
 
Sample link: 
Note: Run the following command in the Package Manager Console to install the ZXing.Net.Mobile barcode scanner. 
Install-Package ZXing.Net.Mobile 
Please let us know if you need any further assistance. 
Regards, 
Chinnu 


Bhalchandra
Replied On July 27, 2017 08:34 AM

i have requirement  to read the bar code from a Image file. please guide me



Chinnu Muniyappan [Syncfusion]
Replied On July 28, 2017 08:25 AM

Hi Bhalchandra, 

Thank you for contacting Syncfusion support. 

As we said earlier, currently we don’t have barcode reader support in UWP platform. So, we have suggested you, to use Zxing barcode scanner API for reading barcode from an image. Please refer the below code snippet and sample for more details. 

             
            //Load the image from the embbeded resource. 
            Stream imgStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("BarcodeReader.Assets.Barcode.png"); 
                  
            //Set the image stream position.      
            imgStream.Position = 0; 
 
            //Get the image RGB data. 
            var BitmapImageDecoder = await BitmapDecoder.CreateAsync(imgStream.AsRandomAccessStream()); 
 
           PixelDataProvider provider = await BitmapImageDecoder.GetPixelDataAsync().AsTask().ConfigureAwait(false); 
            var imageData = provider.DetachPixelData(); 
 
            //initialize the ZXing barcode reader 
            ZXing.BarcodeReader reader = new ZXing.BarcodeReader(); 
 
            //Reader the barcode 
            ZXing.Result[] results = reader.DecodeMultiple(imageData, (int)BitmapImageDecoder.PixelWidth, (int)BitmapImageDecoder.PixelHeight, ZXing.RGBLuminanceSource.BitmapFormat.Unknown); 



Please let us know if you have any concern. 

Regards, 
Chinnu 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;