using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PQScan.BarcodeScanner;
using Bytescout.BarCodeReader;
using System.Drawing;
using System.IO;
using System.Activities;
using System.ComponentModel;
using System.Threading.Tasks;
namespace Testing1
{
public class Readingbarcode : CodeActivity
{
[Category(“Input”)]
[RequiredArgument]
public InArgument FilePath { get; set; }
[Category("Output")]
public OutArgument<string> strResult { get; set; }
protected override void Execute(CodeActivityContext context)
{
//PdfDocument pdf = new PdfDocument();
string filPath = FilePath.Get(context);
PdfReader pdfReader = new PdfReader(filPath);
// int numberOfPages = pdfReader.NumberOfPages;
Reader barcodeReader = new Reader();
barcodeReader.BarcodeTypesToFind.Code39 = true;
barcodeReader.Orientation = OrientationType.VerticalFromBottomToTop;
FoundBarcode[] barcodes = barcodeReader.ReadFrom(filPath);
int numberofBarcodes = barcodes.Count();
List<string> barCodes = new List<string>();
foreach (FoundBarcode barcode in barcodes)
{
int number = 1;
number += barcode.Page;
string holdBarcode = barcode.Value.Split('(')[0].ToString() + "," + number.ToString() + "\n";
barCodes.Add(holdBarcode);
}
string data = string.Join("", barCodes.ToArray());
strResult.Set(context, data);
}
}
}