I have a PDF file that includes a page with the Barcode. The barcode was originally created using DecodeType.Code128
I am using ASPOSE.PDF and Aspose.Barcode to find the barcode and the page number.
var barcodePageNumbers = new List<int>();
var currentPageNumber = 0;
using (PdfConverter converter = new PdfConverter())
{
converter.BindPdf(sourcefilePath);
converter.RenderingOptions.BarcodeOptimization = true;
converter.DoConvert();
while (converter.HasNextImage())
{
currentPageNumber++;
using (var ms = new MemoryStream())
{
converter.GetNextImage(ms);
ms.Seek(0L, SeekOrigin.Begin);
BarCodeReader reader = new BarCodeReader(ms, DecodeType.Code128);
while (reader.Read())
{
var text = reader.GetCodeText();
if (text == _barcodeTextToMatch)
{
barcodePageNumbers.Add(currentPageNumber);
}
}
}
}
}
Every now and then we get bad quality barcode pdf like the one attached herewith. (Note the attached PDF has 3 pages. I have created page 1 and 3 using tool. and the 2nd page which has barcode is from the original PDF.)
The code above works as long as the barcode quality is good. but if the quality is bad then it not able able to recognize its barcode.
What other optimization technique can be used here?