Nearest checkbox

Searches for the checkbox nearest to the anchor in any direction, and returns a boolean indicating if it's selected or unselected.

Use this method as an alterative to the Checkbox method. The advantage of the Nearest Checkbox method is that it's more flexible, requires less configuration, and recognizes a wider range of checkbox formats. The disadvantage is that it's slower than the Checkbox method, because the Nearest Checkbox method uses OCR.

Parameters
Examples

Parameters

Note: For the full list of parameters available for this method, see Global parameters for methods. The following table shows parameters most relevant to or specific to this method.

keyvaluesdescription
id (required)nearestCheckboxSensible returns true for selected checkboxes and false for unselected checkboxes. This method uses Azure Form Recognizer’s checkbox detection. This detection uses OCR and machine learning and captures a wide range of checkbox formats.
position (required)left, rightDefines the starting point for searching for the nearest selection mark. Sensible searches outward from this point in all directions. right specifies starting at the midpoint of the anchor line's right boundary, and left specifies starting at the midpoint of the anchor line's left boundary.
offsetXnumber in inches. default: 0Searches for a selection mark starting at a point offset horizontally from the point defined by the Position parameter.
offsetYnumber in inches. default: 0Searches for a selection mark starting at a point offset vertically from the point defined by the Position parameter.

Examples

The following example shows extracting the checkboxes that are nearest to their respective anchors. For a checkbox that is nearer to another line's checkbox than to its own checkbox, the example shows using an Offset parameter close the gap:

{
  "fields": [
    {
      "id": "checkbox_right",
      "anchor": "checkbox",
      "method": {
        "id": "nearestCheckbox",
        "position": "right"
      }
    },
    {
      "id": "checkbox_below",
      "anchor": "below",
      "method": {
        "id": "nearestCheckbox",
        "position": "right"
      }
    },
    {
      "id": "checkbox_no_border",
      "anchor": "border",
      "method": {
        "id": "nearestCheckbox",
        "position": "right"
      }
    },
    {
      "id": "checkbox_far",
      "anchor": "far",
      "method": {
        "id": "nearestCheckbox",
        "position": "left",
        "offsetX": -2
      }
    }
  ]
}

Example document
The following image shows the example PDF used with this example config:

Click to enlargeClick to enlarge

Example PDFDownload link

Output

{
  "checkbox_right": {
    "type": "boolean",
    "value": true
  },
  "checkbox_below": {
    "type": "boolean",
    "value": false
  },
  "checkbox_no_border": {
    "type": "boolean",
    "value": true
  },
  "checkbox_far": {
    "type": "boolean",
    "value": false
  }
}

Did this page help you?