find()

Method of the data object that finds the first occurrence of a string starting from the current position.

find(stringToFind, leftConstraint, rightConstraint)

Finds the first occurrence of a string starting from the current position. The search can be constrained to a series of characters (in a text file) or to a vertical strip (in a PDF file) located between the given constraints.
The method returns null if the string cannot be found. Otherwise it returns a RectValueText (if the data source is a text file) or RectValuePDF (if the data source is a PDF file) object. This object contains the absolute Left, Top, Right and Bottom coordinates of the smallest possible rectangle that completely encloses the first occurrence of the string. The coordinates are expressed in a number of characters if the data source is a text file, or in millimetres if the data source is a PDF file.

Partial matches are not allowed. The entire string must be found between the two constraint parameters.

The data.find() function only works on the current page. If the record contains several pages, you must create a loop that will perform a jump from one page to another to do a find() on each page.

Note: Calling this method does not move the current position to the location where the string was found. This allows you to use the method as a look-ahead function without disrupting the rest of the data mapping workflow.

stringToFind

String to find.

leftConstraint

Number indicating the left limit from which the search is performed. This is expressed in characters for a text file, or in millimetres for a PDF file.

rightConstraint

Number indicating the right limit to which the search is performed. This is expressed in characters for a text file, or in millimetres for a PDF file.

Examples

To look for the word "text" on an entire Letter page (8 1/2 x 11 inch), the syntax is:

data.find("text", 0, 216);

The numbers 0 and 216 are in millimeters and indicate the left and right limits (constraints) within which the search should be performed. In this example, these values represent the entire width of a page. Note that the smaller the area is, the faster the search is. So if you know that the word "text" is within 3 inches from the left edge of the page, provide the following:

Copy
data.find("text", 0, 76.2); //76.2mm =  3*25.4 mm

The return value of the function is:

Copy
Left=26,76, Top=149.77, Right=40,700001, Bottom=154.840302

These values represent the size of the rectangle that encloses the string in full, in millimeters relative to the upper left corner of the current page.

Text file

find(stringToFind String, leftConstraint Number, rightConstraint Number) : RectValueText

Finds the first occurrence of stringToFind starting from the current position. The search can be constrained to the series of characters located between leftConstraint and rightConstraint, expressed in characters. The method returns null if stringToFind cannot be found, otherwise it returns aRectValueText object.

The RectValueText contains the absolute Left, Top, Right and Bottom coordinates of the smallest possible rectangle that completely encloses stringToFind.

Note that partial matches are not allowed, i.e. the entire stringToFind must be found between the leftConstraint and rightConstraint parameters.

Note also that calling this method does not move the current position to the location where stringToFind was found, allowing you to use the method as a look-ahead function without disrupting the rest of the workflow.