GdPicture不仅可以对多种图片、图像文档进行各种处理,还可以结合控件提供的添加模块实现多种其他功能,条码生成和识别是控件提供的一个可添加模块,开发人员通过该模块可以实现一维和二维条形码的生成与识别,下面的代码讲述了如何快速从PDF文档中识别OR条形码:
GdPicturePDF oGdPicturePDF = new GdPicturePDF();
if (oGdPicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK) {
//Step2: Convert the desired PDF page to GdPicture Image
oGdPicturePDF.SelectPage(1);
int imageID = oGdPicturePDF.RenderPageToGdPictureImage(200, false);
if (imageID != 0) {
//Step3: Barcode recognition from GdPicture Image
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
oGdPictureImaging.BarcodeQRReaderDoScan(imageID, BarcodeQRReaderScanMode.BestQuality);
oGdPictureImaging.ReleaseGdPictureImage(imageID);
for (int i = 1; i <= oGdPictureImaging.BarcodeQRReaderGetBarcodeCount(); i++) {
MessageBox.Show("Barcode no: " + i.ToString() + Strings.Chr(13) +
"Barcode version: " + oGdPictureImaging.BarcodeQRReaderGetVersion(i).ToString + Strings.Chr(13) +
"Barcode value: " + oGdPictureImaging.BarcodeQRReaderGetBarcodeValue(i));
}
oGdPictureImaging.BarcodeQRReaderClear();
}
oGdPicturePDF.CloseDocument();
}