What it does
This node filters shape trees based on Unicode text, position, item name, or index. Items that do not match the filter criteria are passed to a separate output.
Use it for
- Filtering specific shape trees that cannot be selected using the Select Shapes or Select Shapes by Reference nodes due to lack of distinctive formatting.
- Filtering shape trees containing specific text. Supports regular expressions.
- Filtering shape trees by index or item name.
- Filtering shape trees by position on the page (
pageBBoxes) or in the document (docBBox).
How to use it
- Drag and drop the node from the Node Library into your template:
Node Library > Folder Shapes > Folder Filter - Connect the node with other nodes in the Data Flow of your template.
- Specify the settings in the Node Properties task pane.
Node Input
Connect a node that provides the shape trees to be filtered to the Items input port.
Node Output
- Filtered Items: Shape trees that match the filter expression.
- Unfiltered Items: Shape trees that do not match the filter expression.
Node Properties
Node Name
You can assign a custom name to the node to help identify its purpose within your template.
Filter Expression
Define the condition used to filter shape trees.
Available variables:
-
item: the current item being processed from the input list.itemhas the same properties as a shape tree object. -
index: the zero-based index of the item in the input list -
first: the first item in the input list -
last: the last item in the input list -
count: the total number of items in the input list
Expected return type: boolean
Important: Using regular expressions may significantly impact performance. Use them only when necessary.
Example 1: Filtering by text
item.text = "This is an example."
Filters shape trees containing the Unicode text "This is an example.". This also works when the text is split across multiple shapes, such as "This is " and "an example.".
Example 2: Filtering by text with regular expressions
item.text match "test" or item.text match "^Ex"
Filters all shape trees that contain "test", or start with "Ex".
Example 3: Filtering by item name
item.name = "P"
Filters all shape trees with the item name "P".
Example 4: Filtering by index
index = 0 and index in [2 .. 5] and index = count -2
Filters the first item (index = 0), items with indices 2 through 5 and the second-to-last item.
Example 5: Filtering first or last item
first and last
Filters the first and last items in the input list.
Example 6: Filtering by position
item.pageBBoxes[0].top < 500 and item.pageBBoxes[0].bottom > 400
Filters items whose first page bounding box lies within a vertical range: the top edge is below 500 points and the bottom edge is above 400 points.