/
3 Read Multiple.cs
68 lines (56 loc) · 3.11 KB
/
3 Read Multiple.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using IronBarCode;
using System;
using System.Drawing;
namespace ReadingBarcodesInCSharpTutorial
{
public partial class Examples
{
public static void ReadMultipleFromPdf()
{
// Multiple barcodes may be scanned up from a single document or image. A PDF document may also used as the input image
PagedBarcodeResult[] PDFResults = BarcodeReader.ReadBarcodesFromPdf("MultipleBarcodes.pdf", BarcodeEncoding.All, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.None);
// Work with the results
foreach (var PageResult in PDFResults)
{
string Value = PageResult.Value;
int PageNum = PageResult.PageNumber;
System.Drawing.Bitmap Img = PageResult.BarcodeImage;
BarcodeEncoding BarcodeType = PageResult.BarcodeType;
byte[] Binary = PageResult.BinaryValue;
Console.WriteLine(PageResult.Value+" on page "+ PageNum);
}
}
public static void ReadMultipleFromTiffScan()
{
// Multi frame TIFF and GIF images can also be scanned, and multiple threads will be used automatically in the background for improved performance
PagedBarcodeResult[] MultiFrameResults = BarcodeReader.ReadBarcodesFromMultiFrameTiff("Multiframe.tiff", BarcodeEncoding.AllOneDimensional, BarcodeReader.BarcodeRotationCorrection.High, BarcodeReader.BarcodeImageCorrection.MediumCleanPixels);
// Work with the results
foreach (var PageResult in MultiFrameResults)
{
string Value = PageResult.Value;
int PageNum = PageResult.PageNumber;
System.Drawing.Bitmap Img = PageResult.BarcodeImage;
BarcodeEncoding BarcodeType = PageResult.BarcodeType;
byte[] Binary = PageResult.BinaryValue;
Console.WriteLine(PageResult.Value + " on page " + PageNum);
}
}
public static void MultiThreading()
{
// The BarcodeResult.ReadBarcodesMultiThreaded method allows for faster barcode scanning of multiple images. All threads are automatically managed by IronBarCode.
var ListOfDocuments = new[] { "image1.png", "image2.jpg", "image3.pdf" };
// The true flag at the end allows us to expect multiple barcodes per document.
PagedBarcodeResult[] BatchResults = BarcodeReader.ReadBarcodesMultiThreaded(ListOfDocuments, BarcodeEncoding.All, true);
// Work with the results
foreach (var Result in BatchResults)
{
string Value = Result.Value;
System.Drawing.Bitmap Img = Result.BarcodeImage;
BarcodeEncoding BarcodeType = Result.BarcodeType;
byte[] Binary = Result.BinaryValue;
var InputFileName = ListOfDocuments[Result.PageNumber-1];
Console.WriteLine(Result.Value +" found in file "+ InputFileName);
}
}
}
}