Object Merge Mapping
- Last UpdatedOct 17, 2025
- 7 minute read
PDF documents often contain tabular-like data where related information is displayed in multiple rows or columns. ObjectMergeMapping transforms these tabular entities into row or column-like objects, based on the positions of each word in the table. This therefore requires the text objects to be extracted as words with Xmin and Ymin positions, see Extract Settings to Select Extract contents By Word. Use the <MergeCriteria> configuration to define the criteria used to determine how elements are merged in the mapping process. It contains the following key elements:
-
Tolerance
-
MaxExtentX
-
MaxExtentY
-
Separator
Each of these elements controls a specific aspect of the merge logic, particularly for spatial or geometric data.
Element Definitions
-
<Tolerance>
Specifies the allowable tolerance (usually in units such as pixels or millimeters) when comparing object positions or attributes during the merge process. Objects within this tolerance are considered equivalent for merging purposes.
ListType property determines how objects are grouped for merging—typically by "Row" or "Column". The Tolerance property is used to specify how close two values (such as coordinates) must be to be considered part of the same group.
Interpretation:
-
ListType = "Row":
Tolerance is usually applied to the Y-coordinate (vertical position).
Objects are grouped as being in the same "row" if their Y values differ by less than or equal to the specified Tolerance.
Example: If Tolerance = 2, objects with Y-coordinates within 2 units are grouped together.
-
ListType = "Column":
Tolerance is usually applied to the X-coordinate (horizontal position).
Objects are grouped as being in the same "column" if their X values differ by less than or equal to the specified Tolerance.
Example: If Tolerance = 2, objects with X-coordinates within 2 units are grouped together.
Tolerance is measured from either YMin or XMin, depending on the ListType specified in your MergeCriteriaType:
-
If ListType is "Row", tolerance is measured from the YMin attribute of each object.
-
If ListType is "Column", tolerance is measured from the XMin attribute of each object.
-
-
-
<MaxExtentX>
Defines the maximum allowed extent (width) in the X direction for the objects being merged. This is typically used to filter or limit the merge operation to objects that do not exceed this width.
-
<MaxExtentY>
Defines the maximum allowed extent (height) in the Y direction for the objects being merged. This is typically used to filter or limit the merge operation to objects that do not exceed this height.
-
<Separator>
Specifies the string used to separate multiple values when merging attributes or concatenating data fields. This is useful when combining lists or sets of values into a single string.
Example Usage
When a PDF document has spatially related text strings extracted as Words, such as items in a table's row, you can merge them into a single object based on their X and Y positions. The Gateway identifies the text strings that align in a row (or column) if their Ymin (or Xmin) position is within the tolerance value of the first string's Ymin (or Xmin) value. If a string's Xmin position is within the MaxExtentX value of the first string's Xmax (first string Xmax + MaxExtentX >= second string Xmin), then the two strings will be concatenated into one string separated by a single space. Otherwise, the next string in the X (or Y) direction of the row (or column) will be treated as the next element in the list, and concatenated with the first string but with the insertion of a defined separator.
Configuration:
<Object >
<MergeCriteria>
<ListType Value="Row" />
<Tolerance Value="2" />
<MaxExtentX Value="8" />
<Separator Value=":" />
</MergeCriteria>
</Object>
Notes:
-
Irrespective of the ListType configuration (Row/Column), the MaxExtentX value only applies in the X direction.
-
Blank values are not considered.
-
ListType values are case insensitive.
Example:
Input text is as follows:
|
Identifier |
Area |
Type |
Number |
Batch |
|
P-101 |
Cambridge |
Hydro |
1 |
Batch 1 |
|
Valve 26 |
Histon |
Hydro |
1 |
When the above configuration is applied, the Gateway will merge all objects on each row as ListType = "Row", where each concatenated value is separated by " : ".
Note: The objects in the last row are extracted with their X and Y extents as:
-
Valve (Xmin 5, Xmax 10, Ymin 6, Ymax 6)
-
26 (Xmin 12, Xmax 14, Ymin 6, Ymax 6)
-
Histon (Xmin 24, Xmax 30, Ymin 6.2, Ymax 6.2)
-
Hydro (Xmin 40, Xmax 45, Ymin 5.8, Ymax 5.8)
-
1 (Xmin 55, Xmax 56, Ymin 6, Ymax 6)
The "Valve" and "26" objects are separated with a single space as both are within the radius of the MaxExtentX value.
The separate string objects are replaced by 3 new list objects with attribute values of:
Object 1 attribute value = "Identifier : Area : Type : Number : Batch"
Object 2 attribute value = "P-101 : Cambridge : Hydro : 1 : Batch 1"
Object 3 attribute value = "Valve 26 : Histon : Hydro : 1 "
Processing Multiple Tables in a Page
After texts are aligned in a row then TableIndex (1 ... N) and RowIndex (1 ... M) attributes will be added to each Row object. The TableIndex value is set to 1 for the first row in a Page. The MaxExtentY value is used to determine which rows belong to which table. If the difference in Y position between rows is less than MaxExtentY, then the subsequent row is assigned to the current table and RowIndex for that table is incremented by 1. If the difference is greater than MaxExtentY, then a new table is created (the TableIndex value will be incremented) for the subsequent row, and RowIndex for this new table will be reset to 1.
Configuration:
<Object >
<MergeCriteria>
<ListType Value="Row" />
<Tolerance Value="2" />
<MaxExtentX Value="8" />
<MaxExtentY Value="20" />
<Separator Value=":" />
</MergeCriteria>
</Object>
For example, if the input text looks like:
|
Identifier |
Area |
Type |
Number |
Batch |
|
P-101 |
Cambridge |
Hydro |
1 |
Batch 1 |
|
Valve 26 |
Histon |
Hydro |
1 |
|
Part ID |
Name |
Material |
Size |
|
Part 1 |
Bolt |
Stainless Steel |
8 mm |
|
Part 2 |
Gasket Black |
Nylon |
20 diam inner, 30 outer |
The result of Object Merge mapping will be 6 row objects in two tables with concatenated lists in their Content attribute:
Row object 1: TableIndex=1, RowIndex=1, Content="Identifier : Area : Type : Number : Batch"
Row object 2: TableIndex=1, RowIndex=2, Content="P-101 : Cambridge : Hydro : 1 : Batch 1"
Row object 3: TableIndex=1, RowIndex=3, Content="Valve 26 : Histon : Hydro : 1 "
Row object 4: TableIndex=2, RowIndex=1, Content="Part ID : Name : Material : Size"
Row object 5: TableIndex=2, RowIndex=2, Content="Part 1 : Bolt : Stainless Steel : 8 mm"
Row object 6: TableIndex=2, RowIndex=3, Content="Part 2 : Gasket : Black Nylon : 20 diam inner, 30 outer"
Below is another example of how to use these elements within a <MergeCriteria> block in your XML configuration when texts in a cell are in different rows:
<MergeCriteria>
<ListType Value="ROW"/>
<Tolerance Value="5"/>
<MaxExtentX Value="100"/>
<MaxExtentY Value="50"/>
<Separator Value=";"/>
</MergeCriteria>
Explanation:
-
ListType Value="ROW": Specifies the type of list (for example, "ROW" or "COLUMN").
-
Tolerance Value="5": Objects within 5 units are considered for merging.
-
MaxExtentX Value="100": Only objects with a width up to 100 units are merged.
-
MaxExtentY Value="50": Only objects with a height up to 50 units are merged.
-
Separator Value=";": When merging multiple attribute values, they are joined using a semicolon.
Example:
|
Tag |
Description |
Classification |
Discipline |
Attribute |
|
P-101 |
Pump 101 |
Pump |
Process Management |
TestAttribute1 |
|
P-102 |
Pump 102 |
Pump |
Process Controlling |
TestAttribute2 |
|
P-103 |
Pump 103 |
Pump |
Process Alignment |
TestAttribute3 |
If we use the below values in ObjectMergeMapping.xml:
<MergeCriteria>
<ListType Value="Row" />
<Tolerance Value="15" />
<MaxExtentX Value="20" />
<MaxExtentY Value="10" />
<Separator Value="," />
</MergeCriteria>
Here, ListType="Row" means objects are grouped by their YMin value (vertical position).
Tolerance=15 means any objects whose YMin values are within 15 units of each other are considered to be in the same row group.
What happens:
The YMin of each object is checked. If two objects have YMin values that differ by 15 or less, they are grouped together.
MaxExtentX=20: When merging horizontally, objects are merged if their XMin/XMax values are within 20 units.
Objects in each row group by XMin (left to right) are sorted. It then checks if the next object’s XMin is within MaxExtentX of the current object’s XMax. If so, they are merged into a single object.
The "Discipline" column for P-101 is "Process Management" (split across two cells/objects: "Process" and "Management").
-
Similarly, for P-102: "Process Controlling" (split as "Process" and "Controlling").
-
For P-103: "Process Alignment" (split as "Process" and "Alignment").
Merging logic:
All objects in the same row (YMin within 15 units) are grouped.
"Process" and "Management" are close enough horizontally (XMin/XMax within 20 units), so they are merged into one object: "Process Management".
The same happens for "Process" + "Controlling" and "Process" + "Alignment".
"Process" and "Management" become a single merged object: "Process Management".
"Process" and "Controlling" become "Process Controlling".
"Process" and "Alignment" become "Process Alignment".
The tolerance allows for small misalignments in Y (row grouping).
The max extent in X allows for merging adjacent words/cells that are part of the same logical value but may have been split during extraction.
Key Points:
-
YMin + Tolerance: Groups objects into rows.
-
XMin/XMax + MaxExtentX: Merges horizontally adjacent objects in the same row.
-
Result: Split words/cells are combined into the intended full value.
Let’s consider the same example with ListType="Column":
<MergeCriteria>
<ListType Value="Column" />
<Tolerance Value="15" />
<MaxExtentX Value="20" />
<MaxExtentY Value="34" />
<Separator Value="," />
</MergeCriteria>
ListType="Column": Objects are grouped by their XMin value (horizontal position).
Tolerance=15: All objects whose XMin values are within 15 units are grouped as a single column.
This allows for small misalignments in the X direction. All objects that are visually in the same column (even if slightly misaligned) are grouped together.
Within each column group, objects are sorted by YMin (top to bottom).
MaxExtentY=34: Objects whose YMin/YMax values are within 34 units vertically are merged together.
This merges vertically adjacent fragments in the same column.
The "Discipline" column for P-102 and P-103 is split into two objects each:
"Process" , "Management" for P-101
"Process" , "Controlling" for P-102
"Process" , "Alignment" for P-103
All "Process", "Management ", "Controlling", and "Alignment" objects in the same column (XMin within 15 units) are grouped.
Within that column, the code checks the YMin/YMax of each object:
"Process" and "Controlling" are within 34 units vertically, they are merged as "Process Controlling".
"Process" and "Alignment" are within 34 units, they are merged as "Process Alignment".
The split values are merged into single objects: "Process Controlling" for P-102 and
"Process Alignment" for P-103.