Ví dụ này minh họa cách trích xuất mã vạch từ tệp PDF bằng các tùy chọn trích xuất mã vạch cụ thể.
C#
// Tải tệp PDF bằng lớp Parser
using (Parser parser = new Parser("input.pdf"))
{
// Xác nhận hỗ trợ trích xuất mã vạch
if (!parser.Features.Barcodes)
{
return;
}
// Sử dụng các tùy chọn mã vạch để lọc kết quả
BarcodeOptions options = new BarcodeOptions(QualityMode.Low, QualityMode.Low, "QR");
// Lấy dữ liệu mã vạch từ tài liệu
IEnumerable<PageBarcodeArea> barcodes = parser.GetBarcodes(options);
// Xử lý danh sách mã vạch đã trích xuất
foreach (PageBarcodeArea barcode in barcodes)
{
Console.WriteLine("Page: " + barcode.Page.Index.ToString());
Console.WriteLine("Value: " + barcode.Value);
}
}