I'm encountering some problems during detecting barcode in pdf file.
I acquire with a scanner the same document, then I create files with different extensions.
Then I'm trying to detect in this document a generic Code39 barcode.
For JPEG, PNG, BMP, TIFF no problem: I use the method CreateGdPictureImageFromFile, then Barcode1DReaderDoScan and my barcodes are detected.
So, when I have a PDF file, I use the new GdPicturePDF class available in GdPicture v.8.
Here is my code snippet:
Code: Select all
GdPicture.GdPicturePDF gdPDF = new GdPicturePDF();
gdPDF.SetLicenseNumber("XXX");
GdPictureStatus gstatus = gdPDF.LoadFromFile(pdfPath, false);
if (gstatus == GdPictureStatus.OK)
{
for (int i = 1; i <= gdPDF.GetPageCount(); i++)
{
// select the current page
if (gdPDF.SelectPage(i))
{
// create image
int imageId = gdPDF.RenderPageToGdPictureImage(72, false);
if (imageId > 0)
{
// searching barcode in i-page
gstatus = gdPicture.Barcode1DReaderDoScan(imageId, Barcode1DReaderScanMode.BestQuality);
if (gstatus == GdPictureStatus.OK)
{
// for each barcode I read info
for (int j = 1; j <= gdPicture.Barcode1DReaderGetBarcodeCount(); j++)
{
Console.WriteLine(gdPicture.Barcode1DReaderGetBarcodeValue(j));
Console.WriteLine(gdPicture.Barcode1DReaderGetBarcodeType(j).ToString());
}
}
gdPicture.Barcode1DReaderClear();
}
}
}
gdPDF.CloseDocument();
}
- in the BMP file I found 3 barcodes
- in the PDF file no barcode is detected.
Anyone can help me?
Thanks.
Michela