# Recognize by Template

Recognizes the specified document by template. This block works with templates created using the "Extract by Template" button on the Sherpa Designer toolbar.

Video with an example of using the block:

{% embed url="<http://sherparpa.ru/videos/ru/recognizetemplates.mp4>" %}

<table data-header-hidden><thead><tr><th width="255" valign="top"></th><th width="293" valign="top"></th></tr></thead><tbody><tr><td valign="top">File Path</td><td valign="top"><p>[Text/List] File path. Supported file formats:</p><ul><li>png;</li><li>jpg;</li><li>pdf.</li></ul><p>The pdf file can be multi-page. A list of image files can be specified.</p></td></tr><tr><td valign="top">Template File Path</td><td valign="top"><p>[Text/List] Path to the template file for recognition. When specifying a list of template files for recognition, each file will be used sequentially until recognition is successfully completed.</p><p>If none of the templates match the document, an exception will be generated with the error of the first template from the list. Using a list can increase the processing speed of multiple templates if their page recognition parameters are the same.</p><p>This block works with templates created using the "Extract by Template" button on the Sherpa Designer toolbar.</p></td></tr><tr><td valign="top">Page Number</td><td valign="top"><p>[Number/Text] Page number in a multi-page pdf file.</p><p>If there is an anchor LastPage, recognition will proceed from the specified number to the page until it is found. If this anchor is not present, only the specified page will be recognized.</p><p>A string with page numbers can be specified, separated by commas. Ranges can also be specified with a dash. For example: "1, 4-7".</p></td></tr><tr><td valign="top">Replace Module</td><td valign="top"><p>[Text] Allows replacing the specified module in the template with the one specified in the block during recognition. Possible values:</p><ul><li>TesseractOCR;</li><li>YandexVision;</li><li>MicrosoftOCR;</li><li>AbbyyOCR;</li><li>FineReader;</li><li>OCRSpace.</li></ul></td></tr><tr><td valign="top">Replace Scale</td><td valign="top">[Number] Specifies a new scale during recognition by the template. If the value is not specified, the scale from the template settings is used; otherwise, the scale specified in this property is applied.</td></tr><tr><td valign="top">Replace Recognition Language</td><td valign="top">[Text] Allows replacing the specified language in the template with the one specified in the block during recognition.</td></tr><tr><td valign="top">Replace Cell Width</td><td valign="top"><p>[Number] Specifies a new cell width during recognition by the template.</p><p>If the value is not specified, the cell width from the template settings is used; otherwise, the width specified in this property is applied.</p></td></tr><tr><td valign="top">Replace Cell Height</td><td valign="top"><p>[Number] Specifies a new cell height during recognition by the template.</p><p>If the value is not specified, the cell height from the template settings is used; otherwise, the height specified in this property is applied.</p></td></tr><tr><td valign="top">Add "Confidence" Percentage to Tables</td><td valign="top">When enabled, each cell in the table will record not text, but a CellData object. The text can be extracted from the object using the Text property, and the "confidence" percentage can be extracted using the Confidence property.</td></tr><tr><td valign="top">Ignore Anchor Errors</td><td valign="top">If anchors (any) are not found, no errors will be generated. In this case, the anchor area is considered zero.</td></tr><tr><td valign="top">Process All Pages</td><td valign="top">When this option is enabled, all pages in the document will be processed. This mode does not check the LastPage anchor.</td></tr><tr><td valign="top">Attributes</td><td valign="top">[Dictionary] A dictionary with document attributes. For example: "Document Number", "Supplier INN", etc. The parameter CountPage is added to the attributes, which corresponds to the number of pages involved in recognition by the template.</td></tr><tr><td valign="top">Tables</td><td valign="top">[List of Data Tables] Returns a list of data tables. The list is formed based on the data from the template.</td></tr><tr><td valign="top">Anchor Areas</td><td valign="top">[Dictionary] A dictionary with found anchors. The key of the dictionary is the anchor ID, and the value is a rectangle indicating its position on the page. The DPI of the page is assumed to be 300.</td></tr><tr><td valign="top">Attribute Data</td><td valign="top"><p>[Dictionary] A dictionary with found attributes. The key of the dictionary is the attribute name, and the value is an object with attribute data. The object contains a rectangle indicating the position of the attribute on the page. The DPI of the page is assumed to be 300.</p><p>The object also contains a Confidence value indicating the "Confidence" in recognition. Available for Tesseract and YandexVision and has a value from 0 to 100.</p></td></tr><tr><td valign="top">Template Index</td><td valign="top"><p>[Number] The index of the recognized template. This property is relevant if a list is specified in the "Template File Path" property.</p><p>Numbering starts from zero.</p></td></tr><tr><td valign="top">Error Handling Level</td><td valign="top"><p>Select the error handling level. Possible values:</p><ul><li>"Default" - by default;</li><li>"Ignore" - errors are ignored;</li><li>"Handle" - errors are processed.</li></ul><p>If "Default" is selected, the value from the "Start" block of this diagram will be used.</p></td></tr><tr><td valign="top">Message Level</td><td valign="top"><p>Select the message level that blocks will output during operation. Possible values:</p><ul><li>"Default" - by default;</li><li>"Release" - output is disabled;</li><li>"Debug" - main information output;</li><li>"Detailed" - detailed information output.</li></ul><p>If "Default" is selected, the value from the "Start" block of this diagram will be used.</p></td></tr><tr><td valign="top">Error Text</td><td valign="top">[Text] Returns detailed information about the error in case of incorrect execution of the block.</td></tr></tbody></table>
