ตัวอย่างนี้แสดงวิธีการดึงข้อมูลบาร์โค้ดจากไฟล์ PDF โดยใช้ตัวเลือกการดึงข้อมูลบาร์โค้ดที่เฉพาะเจาะจง.
C#
// โหลดไฟล์ PDF ด้วยคลาส Parser
using (Parser parser = new Parser("input.pdf"))
{
// ยืนยันว่าการดึงข้อมูลบาร์โค้ดได้รับการสนับสนุน
if (!parser.Features.Barcodes)
{
return;
}
// ใช้ตัวเลือกบาร์โค้ดเพื่อกรองผลลัพธ์
BarcodeOptions options = new BarcodeOptions(QualityMode.Low, QualityMode.Low, "QR");
// ดึงข้อมูลบาร์โค้ดจากเอกสาร
IEnumerable<PageBarcodeArea> barcodes = parser.GetBarcodes(options);
// ประมวลผลรายชื่อบาร์โค้ดที่ถูกดึงข้อมูล
foreach (PageBarcodeArea barcode in barcodes)
{
Console.WriteLine("Page: " + barcode.Page.Index.ToString());
Console.WriteLine("Value: " + barcode.Value);
}
}