Identify Line Items in the Input (Patterns)
    • 13 Dec 2024
    • 10 Minutes to read
    • Contributors
    • PDF

    Identify Line Items in the Input (Patterns)

    • PDF

    Article summary

    Patterns are used within conditional areas to recognize specific line items. For example, a pattern is used to recognize data elements that are contained in an invoice or order line, so that you can identify and add line item data to the output document.

    Patterns are defined in Lasernet Developer’s pattern mode, which is activated by clicking the Pattern tool in the toolbar.

    The effect of clicking the button depends on the type of input data that the form accepts.

    Refer to the information that corresponds to the form’s input data type:

    Text input data

    In pattern mode, a panel is shown on the right-hand side showing already defined patterns and controls for adding, removing, editing and changing the priority of patterns.

    You can change the priority of a pattern by highlighting it and moving it up or down the list using the Move Up and Move Down buttons.

    To specify a pattern in the data, see Setting up a Pattern.

    Note

    Click the Back button or close the Patterns panel to exit pattern mode.

    XML input data

    The button enables pattern mode. To specify a pattern in the data, see Setting up a Pattern.

    Setting up a Pattern

    The process of setting up a pattern depends on the type of input data that the form accepts.

    Refer to the information that corresponds to the form’s input data type:

    Text input data

    To define a pattern, first use the Select tool to highlight the line(s) to be included. Commonly, this is the same line as used in the line criterion.

    Please note the light green pattern marker on the left side of the screen. The pattern marker is used as a guideline while defining patterns. The size of the marker corresponds with the pattern height defined in the Pattern Properties.

    Patterns are set up by selecting the Line Criterion tool and drawing a rectangle around the individual elements of the pattern. See the example below:

    In the above example you can see a grey box representing a pattern criterion. In the example, the pattern matches any rows containing an 8-character long alpha-numeric string located between columns 21 to 28.

    When a criterion is marked using the Line Criterion tool, a dialog appears showing the properties of the element.

    The Edit Criterion dialog contains the following settings.

    Property

    Description

    Row

    The row number within the pattern. This value is normally 1, reflecting the actual row where the criterion was found, though it is possible to set other values e.g., setting the value to 2 includes the current row and, if the criterion matches, the content on the row underneath, whilst setting a value of -1 tests the criterion against the row above instead.

    Start Col

    Start column for the criteria.

    End Col

    End column for the criteria.

    Match

    The expression that is matched by the pattern. This can be edited to match alphanumeric values rather than an explicitly defined text string. In the example above, the text string can also be changed to ????????, resulting in the pattern matching all rows containing any string at the specified position.

    Regular ex.

    This checkbox indicates that the match string is a regular expression.

    Case sensitive

    This checkbox indicates whether the match string is case sensitive or not.

    The area selected is initially contained in the Match field. The criteria can now be edited to make it generic which is essential for the pattern to be able to recognize other similar data elements.

    Wildcards

    These are the available wildcards used for defining a pattern.

    Wildcard

    Description

    ?

    Indicates any character including spaces.

    X

    Indicates a letter – not numbers and spaces.

    9

    Indicates a number from 0-9

    $

    Indicates a number, spaces, comma, period and “-“

    §

    Indicates the letters x or X

    ¤

    Indicates the digit 9

    Note

    Wildcards are not used in “Regular ex.” mode.

    XML input data

    XML files typically contain multiple item lines. Therefore it is likely that you will need to use the pattern tool to define and recognize them.

    An XML invoice could be expressed using a tag named <BillingInformation/ItemLine> with sub tags containing the description and amount. Each <BillingInformation/ItemLine> tag would then have an ID field uniquely identifying the tag within the XML file.

    In the example below, all the <BillingInformation/ItemLine> tags will be mapped to lines of an invoice created by Lasernet.

    To define a range of tags as a pattern, mark the relevant tag using the Pattern tool. An example of which can be seen in the picture above. The <BillingInformation/Header> tag has been selected as the Start pattern criterion using an empty Match field and exists selected as the Operator. This will force Lasernet to test if the XML file contains the tag <BillingInformation/Header> and recognize it as a pattern.

    When you have selected a tag as the Start pattern criteria, all of the corresponding tags are marked in green. The individual information items can now be marked within the tag using the Rearrange tool.

    Note

    The node path is relative to the top node, meaning that the name of the top node should not be included.

    Edit a Pattern

    The Pattern Properties window enables you to edit a pattern.

    Refer to the information that corresponds to the form’s input data type:

    Text input data

    A pattern can be edited by selecting it in the Patterns panel and then performing one of the following actions:

    • Clicking the Edit button on the toolbar of the Patterns panel.

    • Right-clicking the pattern record, and then clicking Edit on the context menu that appears.

    • Double-clicking the pattern record.

    As a result, the Pattern Properties dialog opens.

    XML input data

    Double-click the pattern row in the XML.

    As a result, the Pattern Properties dialog opens.

    Input Tab

    For each pattern, there is a list of predefined criteria under the Input tab. Each criterion contains the following fields: Name, Type, Row, Column and Match.

    The following options are available on the Input tab of the Pattern Properties dialog.

    Property

    Description

    Add

    Clicking the Add button brings up a dialog allowing a new criterion to be manually added.

    Remove

    Removes the selected criterion.

    Move Up

    Moves the selected criterion up one place.

    Move Down

    Moves the selected criterion down one place.

    Edit

    Clicking the Edit button brings up a dialog allowing you to manually change the properties of the selected criterion.

    Pattern Expression

    The Pattern Expression field can be used for defining a set of criteria which must be true (or false). Further information about expressions can be found in the Form Expressions part of Use Criteria.

    Instance(s) qualifiers

    Extends pattern expressions so that the following instances:

    1. All,

    2. First,

    3. Middle which is/are all non-first and non-last,

    4. Last,

    5. Single which is the only one existing line of the pattern

    match those ones which belong to:

    1. Scope of all instance,

    2. Sequence of the pattern instances (no other patterns match lines between two or more sequences),

    3. Region containing instances of the pattern,

    4. Group containing instances of the pattern,

    5. All instances of the pattern in conditional area on a page.

    Both the All Position(s) checkbox and Scope All radio button are selected by default. As such, the remaining controls (First, Middle, Last and Single check boxes, and Sequence, Region, Group and Page radio buttons) are disabled. To enable these controls, clear the All Position(s) checkbox. Various combinations of the controls are possible. Selecting the Page button disables the Single checkbox.

    Pattern Height

    The Pattern height field defines the number of lines that the pattern will span. This can be used to match order lines where the data spans across multiple lines.

    Allow further pattern matching

    After matching the pattern and producing output, the algorithm will then continue to try matching the current line against the rest of the patterns in the list.

    Active

    Toggles a pattern active/inactive. If the check box is selected, the pattern is active and is normally processed. If the checkbox is cleared, the pattern becomes inactive and is not processed or shown in the output or the input.

    Note

    Even if a pattern is hidden and not shown in the output, it is still listed in the Pattern and Rearranges dialog which you can access via Sheet > Patterns and Rearranges.

    Output Tab

    The Output tab of the Pattern Properties dialog contains the following elements.

    Property

    Description

    Progress

    The progress is the height that is reserved for the output of any rearranges belonging to the pattern. It effectively controls where the rearranges for the next pattern are placed so that they flow downwards on the output page. The Y position of rearranges belonging to a pattern are always relative to the current page progress. A progress of 5.0 means that the output of the next pattern match is placed 5 millimetres lower than the current pattern match.

    Progress is relative to the highest rearrange

    Defines the Progress value as the size of the vertical margin between the output rearranges of each pattern match, instead of using an absolute progress for the pattern. This setting implies that rearranges within a pattern can have differing heights and positions, and calculates the total progress accordingly.

    Note

    For script output to be used for relative progress calculations, the scripts must be run as the first pass. See Add Dynamic Elements to a Sheet.

    Group until

    Creates a group starting at every instance of the current pattern and ending by any pattern available in the list (like the OR expression). This setting is related to the Keep rearranges together setting (see below); if the Keep rearranges together checkbox is selected for the group starting instance, Lasernet does not add implicit page breaks until the ending group instance.

    Once the check box is selected, a grid containing patterns and command buttons to manipulate those patterns appear. By default, the current pattern is listed here.

    Clicking the Add command button adds one more current pattern to the grid. To change it to a new one, select the pattern and click the Edit command button, or double click the pattern. Afterwards, select the required pattern among those available in the drop-down list. To remove the pattern from the grid, select it and click the Remove command button.

    Each matching pattern except the current one can be included or excluded by acquiring the Yes or No value respectively. Patterns with the No value do not end the group. The last pattern before the No value pattern ends the group instead.

    GroupName

    Type a descriptive name for the group.

    Additional progress

    Defines the space size between group blocks.

    Keep rearranges together

    If the checkbox is selected, Lasernet keeps all the lines of the rearranges for a pattern together on the same page. If the checkbox is cleared, Lasernet does not keep all rearranges in a pattern together on the same page.

    Remove empty lines from beginning of each page

    If the checkbox is selected, empty pattern lines are removed from the top of each page in the output.

    Remove empty lines from end of each page

    If the checkbox is selected, empty pattern lines are removed from the bottom of each page in the output.

    Widow/orphan control

    If the checkbox is selected, Lasernet avoids putting one or more paragraph-ending lines at the top of a page (widows) or leaving one or more paragraph-starting lines at the bottom of a page (orphans). You can set a number of lines to be considered widow/orphan.

    Page break before

    If the checkbox is selected, a page break is inserted before each pattern output (instance).

    If a group is specified (see Group until), selecting the checkbox will insert a page break before each group block.

    Page break after

    If the checkbox is selected, a page break is inserted after each pattern output (instance).

    If a group is specified (see Group until), selecting the checkbox will insert a page break after each group block.

    Output Area

    From the drop-down list, select an output area to display the pattern. The list contains the default conditional area and custom conditional area(s), if added. Select the <Same As Previous Pattern> option to connect the pattern to the same conditional area as the previous pattern. If the first line of the conditional area is recognized as a pattern with the <Same As Previous Pattern> value, it will be processed in the same way as the default conditional area.

    Output Region

    Select the region where the pattern should be displayed in the output. The list contains the default region and custom regions(s), if added to a defined conditional area.

    Alternating Tab

    The Alternating option comes into effect only when a table is added to the output. You can specify the table settings, including the color of odd/even rows (defined by instance(s) of a pattern), amongst other things (for more details, see Add Tables to a Sheet). There is a pattern instance for every pattern match in the input (represented in the output by object instances added to the pattern).

    See the table below to learn more about the controls available on the Alternating tab of the Pattern Properties dialog.

    Property

    Description

    Detect pattern

    Use the drop-down list to select one of the options you need:

    Odd/Even: Select the option to alternate all available instances belonging to a pattern as odd and even.

    Odd/Even but not in the Same Pattern: Select the option to alternate the current instance as odd and even but only if the previous one belongs to another pattern.

    Same As Previous Pattern: Select the option to keep instances without alternating.


    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.