> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sample 4. Step 5.6: Delivery Address field, grAddress, wgAddressAbove, and DeliveryAddress elements

> Extract the multi-line Delivery Address with a grAddress group, a wgAddressAbove White Gap to bound the search area, and a DeliveryAddress Paragraph element.

Search for the **Delivery Address** field:

* To the right of and below the field name
* Using a **White Gap** element to limit the search area from the bottom
* Using a **Paragraph** element

## Create the grAddress group element

To specify the properties common to all these elements, create a **Group** element.

1. In the **InvoiceHeader** element, create an element of type **Group** and name it **grAddress**.
2. Click the **Relations** tab and specify the following search constraints for the elements of the group:
   * Above the **kwDeliveryAddress** element, **Offset** = -400.
   * Left of the right boundary of the **kwDeliveryAddress** element, **Offset** = -800, **Reference boundary** = **Right**.
   * Right of the left boundary of the **kwDeliveryAddress** element, **Offset** = -50, **Reference boundary** = **Left**.
   * Below the upper boundary of the **kwDeliveryAddress** element, **Offset** = -20, **Reference boundary** = **Top**.

<Frame>
  <img src="https://mintcdn.com/abbyy/8aWHPAJyzWmTqglX/images/flexi-capture/fls/tutorial4_5_6_1_.PNG?fit=max&auto=format&n=8aWHPAJyzWmTqglX&q=85&s=341cbe7bccc32ddf3e5af49b3bd40f7b" alt="Screenshot of the Relations tab of the grAddress Group element properties in ABBYY FlexiLayout Studio, showing the offset and reference boundary constraints that position the group relative to the kwDeliveryAddress element." width="431" height="455" data-path="images/flexi-capture/fls/tutorial4_5_6_1_.PNG" />
</Frame>

## Create the wgAddressAbove White Gap element

To limit the search area for the **DeliveryAddress** element from the bottom, specify a horizontal **White Gap**.

1. In the `InvoiceHeader.grAddress` element, create an element of type **White Gap** and name it **wgAddressAbove**.

2. Click the **White Gap** tab.

3. Under **Orientation**, select **Horizontal**. Set **Min height** to 55.

   <Tip>
     When selecting values for the heights and widths of white gaps, consider the geometry (that is, the boundaries and sizes) of the adjacent image objects in pre-recognition results mode.
   </Tip>

4. Because you are looking for a white gap inside a paragraph, under **Search among objects of type**, select only **Text**.

5. Under **Rubbish**, specify the following values:

   * **Lower threshold limit** – 20.
   * **Upper threshold limit** – 80.
   * **Threshold coefficient (%)** – 10.

   <Frame>
     <img src="https://mintcdn.com/abbyy/8aWHPAJyzWmTqglX/images/flexi-capture/fls/tutorial4_5_6_2_.PNG?fit=max&auto=format&n=8aWHPAJyzWmTqglX&q=85&s=782a2385535990435cb356881b29b9c0" alt="Screenshot of the White Gap tab of the wgAddressAbove element properties in ABBYY FlexiLayout Studio, showing the horizontal orientation, minimum height, and the Rubbish threshold values for the white gap." width="431" height="455" data-path="images/flexi-capture/fls/tutorial4_5_6_2_.PNG" />
   </Frame>

   <Note>
     The values for the **Lower threshold limit**, **Upper threshold limit**, and **Threshold coefficient (%)** properties can only be selected by trial and error. Start with the default values. If the default values do not work, alter them until the white gap is detected on all the test images.
   </Note>

6. Do not specify any additional search constraints and retain the default values for the other options.

7. Click the **Relations** tab.

8. Since the white gap can be located only beneath the keywords of the name **kwDeliveryAddress**, specify the following search constraints:
   * Below the **kwDeliveryAddress** element, **Offset** = 20\
     **Offset** is required to prevent the program from finding white gaps in other areas on the image, for example, between the field name and the text. Click the **Advanced** tab.

9. Since the **Delivery Address** field is not present on all of the images, but when it does occur it is always accompanied by its name, specify the following additional condition in the **Advanced pre-search relations** field: Search for the image object only if the **kwDeliveryAddress** element is detected. In the [FlexiLayout language](/flexi-capture/fls/code/general-code), this condition can be written as follows:

   ```text theme={null}
   If InvoiceHeader.kwDeliveryAddress.IsNull Then DontFind;
   ```

10. Match the FlexiLayout to see if the **wgAddressAbove** element is detected on all images.

11. Since the program sometimes finds more than one white gap in the specified search area and cannot always select the right one, impose additional search constraints. If you examine the images, you will notice that the white gap of interest is the topmost gap in the given search area. Therefore, in the **Advanced pre-search relations** field, specify the following additional condition: Search for an image object closest to the upper boundary of the first page. In the [FlexiLayout language](/flexi-capture/fls/code/general-code), this condition can be written as follows:

    ```text theme={null}
    NearestY: Page(1).RectGlobal.Top;
    ```

12. Temporarily exclude the **InvoiceFooter** element and match the FlexiLayout.

## Create the DeliveryAddress Paragraph element

1. In the `InvoiceHeader.grAddress` element, create an element of type **Paragraph** and name it **DeliveryAddress**.
2. Click the **Relations** tab.
3. Since **DeliveryAddress** can be located only above the white gap **wgAddressAbove**, specify the following search constraint:
   * **Above** the **wgAddressAbove** element, **Offset** = 0.
4. Since the search area for the **DeliveryAddress** element has already been specified at the level of the `InvoiceHeader.grAddress` group, there is no need to specify it again here.
5. Click the **Advanced** tab.
6. Since the name of the **DeliveryAddress** field is also located inside the search area, exclude it to obtain only the value of **DeliveryAddress**. Additionally, there are separators and noise in the search area that are also best excluded. For these reasons, you cannot just exclude the region of the **kwDeliveryAddress** element. It is more appropriate to take the region of the **kwDeliveryAddress** element, enlarge this region so that it encompasses all the noise, and then exclude the resulting rectangle. To do this, specify the following search constraints in the **Advanced pre-search relations** field:

   ```text theme={null}
   If InvoiceHeader.kwDeliveryAddress.IsNull Then DontFind;
   Else
   // Draws a rectangle around the field name (with some offset for the boundaries)
   { Let Left = InvoiceHeader.kwDeliveryAddress.Rect.Left - 100dt;
   Let Top = InvoiceHeader.kwDeliveryAddress.Rect.Top - 100dt;
   Let Right = InvoiceHeader.kwDeliveryAddress.Rect.Right + 20dt;
   Let Bottom = InvoiceHeader.kwDeliveryAddress.Rect.Bottom;
   // Exclude the resulting rectangle from the search area of the field
   ExcludeRect (Left, Top, Right, Bottom);
   }
   ```
7. Temporarily exclude the **InvoiceFooter** element and match the FlexiLayout.
8. Specify the location of the **DeliveryAddress** block as the rectangular region of the detected **DeliveryAddress** element, simplified for clearer display and expanded by 5 dots vertically and horizontally. To do this, select the **Expression** option and type the following expression:

   ```text theme={null}
   Rect outputRect;
   OutputRegion = InvoiceHeader.grAddress.DeliveryAddress.SimplifiedRegion;
   IsNull = InvoiceHeader.grAddress.DeliveryAddress.IsNull;
   OutputRegion.Inflate (5dt, 5dt);
   ```
