ZXing (zebra crossing) is an open-source tool to decode barcodes within images that fall under the Apache 2.0 license. It allows users to scan most of the 1D and 2D barcodes, including QR codes and Data Matrix barcodes.
Barcode OPX is used to optimize the working of ZXing with Syncfusion Essential PDF. This scans the barcode from the PDF document and returns the barcode value and type.
To use the Barcode Reader feature in applications, references need to be added to the following set of assemblies:
Assembly Name |
Description |
---|---|
Syncfusion.Pdf.Base | This assembly contains the core feature for manipulating and saving PDF documents. |
Syncfusion.Compression.Base | This assembly compresses the internal contents of a PDF document. |
Syncfusion.BarcodeReader.OPX | This assembly is the wrapper for the ZXing assembly using ZXing features. |
ZXing | Decodes Barcode within the image |
The following namespace should be included in the application:
If the PDF contains barcodes as shapes, then it internally converts the PDF page into an image and then detects the barcode. The following is the code snippet for this:
BarcodeReader reader = new BarcodeReader("Barcode.pdf", FormatType.PDF);
BarcodeResult result = reader.ScanBarcode();
If the PDF contains a barcode as an image, then the image alone can be extracted and the barcode will then be detected. The following is the code snippet for this:
//Loads the existing document.
PdfLoadedDocument document = new PdfLoadedDocument(txtImageFile.Text);
//Exports the document as images.
images = document.ExportAsImage(0, document.Pages.Count);
foreach (Bitmap img in images)
{
BarcodeReader reader = new BarcodeReader(img);
BarcodeResult result = reader.ScanBarcode();
}
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/BarcodeReaderOPX-1467102689.zip
Supported Barcode types are: Aztec, Codabar, Code 39, Code 93, Code 128, Data Matrix, EAN-8, EAN-13, IMB, ITF, MaxiCode, PDF417, QR Code, UPC-A, UPC-E, MSI.