Hello,
I am attempting to create a series of various sized code-128 bar codes using Aspose.Barcode, then read those various sized bar codes using Aspose.Barcode. Unfortunately, I am having little success.
The various sized, programmatically generated bar codes are printed out, then scanned via a Xerox WorkCenter 5945 (400DPI) to a network folder. Once scanned, a software application utilizing Aspose.Barcode attempts to read the various bar codes and record the data contained within the bar codes. As stated, I am having very little success getting a read of high enough quality to be useful. I have attached a PDF that contains all of the code-128 bar codes, of which only the second one could be read to any level of success.
The code used to create the bar codes and read the bar codes was taken directly from your documentation, but I will provide it to you anyway:
Creation:
BarCodeBuilder bb = new BarCodeBuilder();
Aspose.BarCode.License bcLicense = new Aspose.BarCode.License();
System.IO.Stream bcstream = System.IO.File.OpenRead(Server.MapPath("~") + @"\bin\Aspose.BarCode.lic");
bcLicense.SetLicense(bcstream);
bcstream.Close();
bb.CodeText = “some test value”;
bb.CodeLocation = CodeLocation.None;
bb.SymbologyType = Symbology.Code128;
bb.BackColor = System.Drawing.Color.White;
bb.ImageQuality = ImageQualityMode.Default;
bb.AutoSize = false;
bb.ImageHeight = 8.75f;
bb.ImageWidth = 86.25f;
bb.GraphicsUnit = System.Drawing.GraphicsUnit.Millimeter;
bb.Save(“test.png”, System.Drawing.Imaging.ImageFormat.Png);
Obviously the ImageHeight and ImageWidth differ throughout the provided PDF. 8.75f and 86.25f are what generated the first bar code on the attached document.
Reading:
Aspose.Pdf.Facades.PdfExtractor pdfExtractor = new Aspose.Pdf.Facades.PdfExtractor();
pdfExtractor.BindPdf(“path to document”);
Document pdfDocument = new Document(document.FullName);
pdfExtractor.StartPage = 1;
pdfExtractor.EndPage = 1;
pdfExtractor.ExtractImageMode = ExtractImageMode.ActuallyUsed;
pdfExtractor.ExtractImage();
while (pdfExtractor.HasNextImage())
{
MemoryStream imageStream = new MemoryStream();
pdfExtractor.GetNextImage(imageStream);
imageStream.Position = 0;
using (Aspose.BarCodeRecognition.BarCodeReader barcodeReader = new Aspose.BarCodeRecognition.BarCodeReader(imageStream, BarCodeReadType.Code128))
{
barcodeReader.ImageBinarizationHints RecognitionHints.ImageBinarization.Grayscale;
barcodeReader.ImageBinarizationHints = RecognitionHints.ImageBinarization.MedianSmoothing;
barcodeReader.ImageBinarizationHints = RecognitionHints.ImageBinarization.ComplexBackground;
string barcodeCodeText = barcodeReader.GetCodeText();
string barcodeReadType = barcodeReader.GetReadType().ToString();
float barcodeQuality = barcodeReader.GetRecognitionQuality();
System.Console.WriteLine("Codetext found: " + barcodeCodeText + ", Symbology: " + barcodeReadType + ", Quality: " + barcodeQuality.ToString());
barcodeReader.Close();
}
}
Thank you for your help.