@@ -79,8 +79,6 @@ int main()
7979 for (int i = 0 ; i < count; ++i)
8080 {
8181 const CCapturedResult* result = resultArray->GetResult (i);
82-
83-
8482 if (result->GetErrorCode () == ErrorCode::EC_UNSUPPORTED_JSON_KEY_WARNING)
8583 {
8684 cout << " Warning: " << result->GetErrorCode () << " , " << result->GetErrorString () << endl;
@@ -90,21 +88,31 @@ int main()
9088 cout << " Error: " << result->GetErrorCode () << " ," << result->GetErrorString () << endl;
9189 }
9290
91+ int pageNumber = i + 1 ;
92+
93+ // It is usually necessary to determine 'ImageTagType' based on the original image tag.
94+ // Since imageFile is used, it is directly converted to 'const dynamsoft::basic_structures::CFileImageTag *'.
95+ const CFileImageTag *tag = dynamic_cast <const CFileImageTag *>(result->GetOriginalImageTag ());
96+ if (tag != nullptr )
97+ {
98+ pageNumber = tag->GetPageNumber () + 1 ;
99+ }
100+
93101 // 6. Output the barcode text.
94102 CDecodedBarcodesResult* barcodeResult = result->GetDecodedBarcodesResult ();
95103 if (barcodeResult == nullptr || barcodeResult->GetItemsCount () == 0 )
96104 {
97- cout << " No barcode found in page " << i + 1 << endl;
105+ cout << " No barcode found in page " << pageNumber << endl;
98106 }
99107 else
100108 {
101109 int barcodeResultItemCount = barcodeResult->GetItemsCount ();
102- cout << " Page " << i + 1 << " decoded " << barcodeResultItemCount << " barcodes" << endl;
110+ cout << " Page " << pageNumber << " decoded " << barcodeResultItemCount << " barcodes" << endl;
103111
104112 for (int j = 0 ; j < barcodeResultItemCount; j++)
105113 {
106114 const CBarcodeResultItem* barcodeResultItem = barcodeResult->GetItem (j);
107- cout << " Result " << i + 1 << " -" << j + 1 << endl;
115+ cout << " Result " << pageNumber << " -" << j + 1 << endl;
108116 cout << " Barcode Format: " << barcodeResultItem->GetFormatString () << endl;
109117 cout << " Barcode Text: " << barcodeResultItem->GetText () << endl;
110118 }
0 commit comments