2021.1

Table Of Contents
[0]!=boundaries.getVariable("lastYear"))
{
boundaries.set();
}
}
boundaries.setVariable("lastBand",zeBand[0]);
boundaries.setVariable("lastYear",zeYear[0]);
This script uses the exact same code as used for CSV files, with the exception of parameters
expected by the createRegion() method. The get method adapts to the context (the data source
file) and therefore expects different parameters to be passed in order to achieve the same thing.
Since a text file does not contain column names as a CSV does, the API expects the text
regions to be defined using physical coordinates. In this instance: Left, Top, Right, Bottom.
To try this code, paste the data into a text editor and save the file to Albums.txt. Then create a
new DataMapper configuration and load this Text file as your data file. In the Data Input
Settings, specify On lines as the Page delimiter type with the number of lines set to 1. When
you now set the boundary Trigger to On script, the file will be processed line per line
(triggering the event on each line). Paste the above code in the JavaScript expression field and
click the Apply button to see the result.
Note
The PDF context also expects physical coordinates, just like the Text context does, but
since PDF pages do not have a grid concept of lines and columns, the above parameters
would instead be specified in millimeters relative to the upper left corner of each page. So
for instance, to create a region for the Year, the code might look like this:
region.createRegion(190,20,210,25)
which would create a region located near the upper right corner of the page.
That's the only similarity, though, since the script for a PDF would have to look through
the entire page and probably make multiple extractions on each one since it isn't dealing
with single lines like the TXT example given here.
For more information on the API syntax, please refer to "DataMapper Scripts API" on page382.
Page 392