Mẫu này trình bày việc trích xuất mã vạch từ tài liệu PDF bằng cách sử dụng các cài đặt tùy chỉnh.
Java
// Khởi tạo trình phân tích với tài liệu PDF
try (Parser parser = new Parser("input.pdf"))
{
// Đảm bảo tài liệu hỗ trợ đọc mã vạch
if (!parser.getFeatures().isBarcodes())
{
return;
}
// Áp dụng bộ lọc với các tùy chọn mã vạch
BarcodeOptions options = new BarcodeOptions(QualityMode.Low, QualityMode.Low, "QR");
// Trích xuất mã vạch bằng cách sử dụng trình phân tích
Iterable<PageBarcodeArea> barcodes = parser.getBarcodes(options);
// Xử lý từng kết quả mã vạch
for (PageBarcodeArea barcode : barcodes)
{
System.out.println("Page: " + String.valueOf(barcode.getPage().getIndex()));
System.out.println("Value: " + barcode.getValue());
}
}