pdf2Data 2.1.9 introduces a new rule: groupByTb: dataField. This rule allows the grouping of extracted values in the output XML file, depending on their y coordinate related to the other data field coordinates.
For now, the creation of this rule is available only in the Expert mode of the pdf2Data template editor, which is actually not as difficult as it sounds.
The grouByTb rule is a quite flexible and yet powerful mechanism, which can be used in many use-cases. One of which we will demonstrate here.
In the screenshot below you can see we have two different invoices:
The extraction of the invoice numbers and their related total amounts is our goal here. So we will create 2 data fields (in the User mode):
Total and InvoiceNumber.
Without the groupByTb operator you get the following output:
Which, to be honest is not that useful for further processing.
In our file, we can see that the Invoice word strictly separates the data field values, so we can using it as a value for our groupByTb operator.
But we need to create an auxiliary data field (we are using the Pattern selector here, but the field can be as complicated as necessary):
Then switch to Expert mode (the Expert button in the panel on the left)
For both of our fields we need to add the line: groupByTb: separator after all instructions:
After that, in the User mode, the XML grouping selector will appear in the field's properties.
And the output will be as follows: