//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);
|
Install-Package ZXing.Net.Mobile |
Please let us know if you need any further assistance.
Regards,
Chinnu
i have requirement to read the bar code from a Image file. please guide me
//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);
|