Hi ,
I am trying to achieve the scenario where I need to detect barcode on each page at specific region of the PDF (rectagle area) .
I dont wish to scan the entire pdf file as its heavy and performance hit . Please advise .
Thanks,
Shilpi
// and specify an area to look for the barcode
BarCodeReader reader = new BarCodeReader(new Bitmap("test.png"), new Rectangle(0, 0, 100, 50), BarCodeReadType.Pdf417);
// read all barcodes in the provided area
while (reader.Read() == true)
{
// display the codetext and symbology type of the barcode found
Console.WriteLine("Codetext: " + reader.GetCodeText() +
" Symbology: " + reader.GetReadType().ToString());
}
// close the reader
reader.Close();
Hi ,
I completely agree with the solution provided , but will this handle for all the pages of the pdf ? How will we loop across all the pages ?
Actually I wanted to process around 60 pages and it a performance i hit as it keeps on processing . I want to eliminate this and ensure that all the pages are scanned up for pdf.
Thanks,
Shilpi
Hi ,
Please find the code as under:
int pageIndex = 0;
// bind the pdf
PdfConverter converter = new PdfConverter();
converter.BindPdf(Server.MapPath(savePath1));
converter.RenderingOptions.BarcodeOptimization = true;
converter.DoConvert();
while (converter.HasNextImage())
{
pageIndex++;
MemoryStream pageStream = new MemoryStream();
converter.GetNextImage(pageStream, ImageFormat.Png);
using (BarCodeReader reader1 = new BarCodeReader(new Bitmap(“test.png”), new System.Drawing.Rectangle(0, 0, 100, 50), BarCodeReadType.Pdf417))
{
while (reader1.Read())
{
flag = 1;
}
}
}
I am trying to read barcode from all the pages of the pdf at a specific region . I am getting the error" Parameter is not valid."
Please advise
Thanks,
Shilpi
Hi ,
Please find the Sample Pdf which I am trying ot process , attached in the very first post.
Thanks,
Shilpi
Hi ,
Is there any update on this ? I am kind of stuck up and looking for a quick resolution as the requirement of my application . I need to verify if aspose shall meet up the requirement .Please help me in this as I have to finalize with the tool .
Thanks,
Shilpi
licenceBarCode.SetLicense(@"C:\xxx.lic");
Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
licensePdf.SetLicense(@"C:\xxx.lic");
// bind the pdf document
Aspose.Pdf.Facades.PdfExtractor pdfExtractor = new Aspose.Pdf.Facades.PdfExtractor();
pdfExtractor.BindPdf(@"C:\Input\SamplePdf.pdf");
// set page range for image extraction
pdfExtractor.StartPage = 1;
pdfExtractor.EndPage = 5;
Console.WriteLine("Extracting images.....");
pdfExtractor.ExtractImage();
// save images to stream in a loop
while (pdfExtractor.HasNextImage())
{
Console.WriteLine("Getting next image....");
// save image to stream
pdfExtractor.GetNextImage(imageStream);
imageStream.Position = 0;
Console.WriteLine("Recognizing barcode....");
Aspose.BarCodeRecognition.BarCodeReader barcodeReader =
new Aspose.BarCodeRecognition.BarCodeReader(imageStream);
Aspose.BarCodeRecognition.BarCodeReader.ProcessorSettings.UseAllCores = false;
Aspose.BarCodeRecognition.BarCodeReader.ProcessorSettings.UseOnlyThisCoresCount = 1;
while (barcodeReader.Read())
{
Console.WriteLine("Codetext found: " + barcodeReader.GetCodeText() + ", Symbology: " + barcodeReader.GetReadType().ToString());
}
// close the reader
barcodeReader.Close();
}
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Getting next image....
Recognizing barcode....
Getting next image....
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Getting next image....
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Getting next image....
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Hi ,
The solution provided by you shall work but will scan the extire pdf document from the top for the next image . This will show a performance hit when the document a is heavy pdf.
Is there a way to scan only the rectangular section of each pdf to improve performance? I am trying to upload a 50 pages pdf file.
Thanks,
Shilpi
licenceBarCode.SetLicense(@"C:\xxx.lic");
Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
licensePdf.SetLicense(@"C:\xxx.lic");
// bind the pdf document
Aspose.Pdf.Facades.PdfExtractor pdfExtractor = new Aspose.Pdf.Facades.PdfExtractor();
pdfExtractor.BindPdf(@"C:\Input\SamplePdf.pdf");
// set page range for image extraction
pdfExtractor.StartPage = 1;
pdfExtractor.EndPage = 5;
Console.WriteLine("Extracting images.....");
pdfExtractor.ExtractImage();
// save images to stream in a loop
while (pdfExtractor.HasNextImage())
{
Console.WriteLine("Getting next image....");
// save image to stream
pdfExtractor.GetNextImage(imageStream);
imageStream.Position = 0;
Console.WriteLine("Recognizing barcode....");
Aspose.BarCodeRecognition.BarCodeReader barcodeReader =
new Aspose.BarCodeRecognition.BarCodeReader(objBitmap, new System.Drawing.Rectangle(1657, 2747, 577, 205), Aspose.BarCodeRecognition.BarCodeReadType.Code39Standard);
Aspose.BarCodeRecognition.BarCodeReader.ProcessorSettings.UseAllCores = false;
Aspose.BarCodeRecognition.BarCodeReader.ProcessorSettings.UseOnlyThisCoresCount = 1;
while (barcodeReader.Read())
{
Console.WriteLine("Codetext found: " + barcodeReader.GetCodeText() + ", Symbology: " + barcodeReader.GetReadType().ToString());
}
// close the reader
barcodeReader.Close();
}
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Getting next image....
Recognizing barcode....
Getting next image....
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Getting next image....
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Getting next image....
Recognizing barcode....
Codetext found: TEST8052, Symbology: Code39Standard
Hi ,
Yes I am able to achieve it through the code provided . This workaround seems to work fine for me. By when can I expect the fix of the issue in the upcoming release ?
If I pruchase the product from Aspose now, can the fix of the issue in the upcoming release be integrated in my application later on without any hussle and additional overhead?
Thanks,
Shilpi
The issues you have found earlier (filed as BARCODENET-34336) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.