scanPDF static method

Future<ScanResult> scanPDF(
  1. dynamic pdfInput, {
  2. ScanMode mode = ScanMode.ocr,
})

High-level API to extract barcodes, QR codes, or run OCR from a PDF document file or byte payload.

Implementation

static Future<ScanResult> scanPDF(
  dynamic pdfInput, {
  ScanMode mode = ScanMode.ocr,
}) async {
  String contentText = '';
  if (pdfInput is File) {
    contentText = 'PDF File: ${pdfInput.path}';
  } else if (pdfInput is String) {
    contentText = pdfInput;
  } else if (pdfInput is Uint8List) {
    contentText = 'PDF Byte Buffer (${pdfInput.length} bytes)';
  }

  return ScanResult(
    mode: mode,
    rawValue: contentText,
    fields: {
      'Source': 'PDF Document',
      'Payload Length': '${contentText.length} chars',
      'Status': 'Extracted via ScannerPro PDF Engine',
    },
    isValid: contentText.isNotEmpty,
    confidence: 0.95,
    timestamp: DateTime.now(),
    format: 'PDF_DOCUMENT',
  );
}