Hi,
I am using free Spire.Barcode library.
Problem is, when I am reading barcode from my .pdf file barcodes are read successfully for first time however when reading same file in loop of reading multiple files at a time, I see errors like
- GDI+ generic error
- Parameter is not valid
Please help me to overcome this error. My code is below
using (Stream straem = new FileStream(FileName, FileMode.Open, FileAccess.Read))
{
using (PdfLoadedDocument ldoc = new PdfLoadedDocument(straem, false))
{
for (int i = 0; i < ldoc.Pages.Count; i++)
{
try
{
SizeF pageSize = ldoc.Pages[i].Size;
Bitmap img = ldoc.ExportAsImage(i, new SizeF(pageSize.Width * 3, pageSize.Height * 3), true);
//We are getting error in below function
string[] str = Spire.Barcode.BarcodeScanner.Scan(img, Spire.Barcode.BarCodeType.Code128);
foreach (string item in str)
{
txtProcessed.Text += item + "; ";
}
img.Dispose();
img = null;
}
catch (Exception ex)
{
}
}
}
}