CopyPageTextToTarget

Takes the page text and stores it in a field or variable.

Syntax

bool CopyPageTextToTarget (string Target , string MaxLines)

Parameters

Target
A smart parameter expression that resolves to a field or variable.
MaxLines
A number that specifies the number of lines to write from the current page. A 0 value includes all lines from the page. Smart parameters are supported.

Returns

False, if there is an error. Otherwise, true.

Level

Page.

Details

This action copies the recognized text in a page to a field or variable. The text is copied without any formatting information, only line breaks. Recognition must have been previously performed on the page and a Datacap CCO must exist for the page.

Actions such as "RecognizePage..." perform recognition resulting in the creation of a page CCO. The action "CreateCCOFromLayout" will create a CCO from a layout file, which is created by a "Recognize" action. See these actions in other action libraries for more information on their operation.

After successfully completing, this action will also create a DCO variable on the current page called "PageLineCount" . This variable holds the number of lines written from the page.

Be aware that it is possible for text that appears on the same line on the document to be split into multiple lines. This will usually occur if there is text of different sizes, the baseline of the text is not close enough, or if there is a skew to the page. This situation is unavoidable on some documents.

When page text is copied to a variable or field, no position or confidence information is retained. Only the text itself is copied and any other attributes are discarded. If the destination is a field, the field location properties are not updated with the coordinates of the text.

Important: Use this action with caution as it may put a substantial amount of data within the DCO. The issue might be compounded by using this action on every page within a batch. A large DCO may not perform well. This issue can be improved by storing the text in a field or a field variable instead of a page variable. Regardless of where the page text is stored in the DCO, it is recommended to delete the text from the DCO when it is no longer needed to prevent the DCO size growing too much. This can be achieved by using an rrSet action like this: rrSet("@EMPTY", "@X.MySavedText"), where the variable "MySavedText" would be replaced by the location where the page text has been copied, will empty the variable, removing the text from the DCO.

Example 1

RecognizePageOCR_A()
CopyPageTextToTarget("@X.PageText", "0")
˂Additional actions that use the text>
rrSet("@EMPTY", "@X.PageText")

The action, RecognizePageOCR_A, recognizes the text on the current page and creates a CCO for the page, which contains the recognition results for use by follow on actions. The CopyPageToTarget action places the recognized page text into a variable called "PageText" on the current page as plain text. The action CopyPageTetToTarget also creates a variable that is called "PageLineCount" that has the number of lines that are copied from the page. Next, any number of actions can use the PageText variable as needed. Once the work is done, the page text is deleted from the DCO using the rrSet action.

Example 2

RecognizePageOCR_A()
CopyPageTextToTarget("@X\Field1", "4")

This example performs full page recognition and then copies the first 4 lines of page text to a child field called "Field1". It also creates a variable on the current page object called "PageLineCount" that has the number of lines that are copied from the page.