Document Capture in Java

Demonstrates how to scan a document or form and acquire specific data from that printed material based on a defined template.

Download Source

Product

DataWedge - 11.4

Devices

All supported Zebra Android Nougat (v7.0) or above devices

Overview

Document Capture provides the capability to scan a document or form and acquire specific data from that printed material based on a defined template. It is part of NextGen SimulScan in DataWedge. The templates are generated from NG SimulScan Template Builder. This sample demonstrates how to use Document Capture with Anchor Barcode to capture an address and signature from a document or form based on the barcode scanned. The address and signature are captured as separate images. This is useful in situations such as delivery operations for proof of delivery.

This sample performs the following:

  1. Register a broadcast receiver to listen for DataWedge intents.
  2. Create DataWedge profile "DocumentCaptureProfile" if it does not exist. The result is retrieved from the broadcast receiver. If the profile does not exist, it creates the profile with the following NextGen SimulScan configurations:
    • Set scanning mode to Document Capture.
    • Set the Intent Output action, category and delivery mechanism (broadcast).
    • Enable content provider.
    • Associate this sample application to the profile.
  3. When scanning, the address and signature fields from the document "AnchorBarcodeTemplate.pdf" are captured as separate images based on specifications in the "SignatureAndAddressSeparately.xml" template. The height and width of the image output is adjusted.
  4. Display the captured data (address and signature) as separate images.

This sample application is only intended for educational purposes, demonstrating the use of DataWedge intent API(s).

Requirements

APIs Used

DataWedge API App Functionality
Create Profile Create the profile with specific parameters for Document Capture (see step 2 above).
Create Profile Delete the profile if profile creation fails.
Get Profiles List Get the list of DataWedge profiles on the device to check if a profile exists.
Set Config Set the appropriate configurations specified.
Soft Scan Trigger Start/stop or toggle the software scan trigger.

Using This Sample

  1. Download and build the sample app.

  2. Copy and install the sample app to the device.

  3. Follow instructions to import template "SignatureAndAddressSeparately.xml" to the device.

  4. Launch the sample app.

    • DataWedge profile “DocumentCaptureProfile” is created if it does not exist.
    • If profile creation fails, the profile is deleted. Tap Re-create profile to attempt to recreate the profile.
  5. Tap Start/Stop Scanning to start the scan.

  6. Scan the document "AnchorBarcodeTemplate.pdf". If successful, decoded data is received by the broadcast receiver and processed based on the action given in the Intent Output, in this case Broadcast intent. A message appears indicating the data processed successfully.

  7. Based on the sample template, the address and signature are captured and displayed as separate images.

  8. Tap Clear Scan Data to clear the data displayed.


Related guides: