Hello,
Thanks for your inquiry.
Below are my answers to your questions.
1 & 2. Sorry that our Spire.Barcode doesn't support reading barcodes from a file with multi-pages currently. If read an multi-pages tiff and each page contains one barcode, only the first page 's barcode could be scanned. For this case, one approach is to split the multi-pages tiff to multiple images and then read barcode from these images respectively. Please refer to the following code.
- Code: Select all
Image tiffImage = Image.FromFile("Input.tiff");
//Split Tiff
Image[] images = SplitTIFFImage(tiffImage);
//Read barcode from images
foreach (Image img in images)
{
Bitmap bmp = new Bitmap(img);
string[] BarcodeValues = Spire.Barcode.BarcodeScanner.Scan(bmp);
}
public static Image[] SplitTIFFImage(Image tiffImage)
{
int frameCount = tiffImage.GetFrameCount(FrameDimension.Page);
Image[] images = new Image[frameCount];
Guid objGuid = tiffImage.FrameDimensionsList[0];
FrameDimension objDimension = new FrameDimension(objGuid);
for (int i = 0; i < frameCount; i++)
{
tiffImage.SelectActiveFrame(objDimension, i);
using (MemoryStream ms = new MemoryStream())
{
tiffImage.Save(ms, ImageFormat.Tiff);
images[i] = Image.FromStream(ms);
}
}
return images;
}
3. Our Spire.Barcode only supports reading barcode from image. Reading from a PDF file is not available at present. However, you can use our Spire.PDF (
Spire.PDF Pack(Hot Fix) Version:5.2.3) to convert PDF pages to images firstly, and then read barcodes from these images. Sample code is shown as follows.
- Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("Input.pdf");
List<Bitmap> images = new List<Bitmap>();
//Save Pdf pages to images
for (int i = 0; i < doc.Pages.Count;i++ )
{
Bitmap img = (Bitmap)doc.SaveAsImage(i);
images.Add(img);
}
//Read barcode from images
foreach (Bitmap bmp in images)
{
string[] BarcodeValues = Spire.Barcode.BarcodeScanner.Scan(bmp);
}
4. Our Spire.Barcode supports reading rotated barcode. Just go ahead, if there is any question, please feel free to write back.
Finally, I recommend that you evaluate our commercial version (
Spire.BarCode for .NET Version:3.1), since the commercial one is stronger and supports more barcode types than the free one.
Sincerely,
Nina
E-iceblue support team