Skip to main content
This object represents a single block. When recognizing a page, ABBYY FineReader Engine first analyzes its layout and detects blocks of various types on the page. Blocks determine how the image areas are recognized and contain recognized information after recognition. Each block on the page belongs to one of the nine types: text, table, raster picture, vector picture, barcode, checkmark, checkmarks group, separator, and separators group. The type of the block is defined by the Type property. The Block object exposes methods which typecast it to the one of its child objects and thereby provide access to the extended attributes of a block of specific type. The position of the block on an image is defined by its region (the Region property) and the layer to which the block belongs (the BlockLayerType property).
The block you obtain from the layout of an FRPage will become invalid after a call to any of the methods that perform layout analysis (such as Analyze or Process ) for this page or the document it belongs to. After analysis, find the block you require in the new layout and continue working with the new Block object.

Properties

Name

Type

Description

Application

Engine, read-only

Returns the Engine object.

Main attributes

Region

Region

Provides access to the block region. A region is a collection of rectangles. Unlike other types of blocks, a table block may have no more than one rectangle in its region, that is why an attempt to assign a region with more than one rectangle to a table block will result in an error. The region is defined by coordinates of its rectangles (in pixels) upon the deskewed black-and-white plane of the corresponding image.

The property returns a constant object. To change the block region, you must at first obtain an intermediate Region object using the IEngine::CreateRegion method, change the necessary parameters, and then assign the obtained object to the property.

Type

BlockTypeEnum, read-only

ABBYY FineReader Engine uses the following types of blocks: text, table, raster picture, vector picture, barcode, checkmark, checkmarks group, separator, separators group, and autoanalysis. (Autoanalysis blocks are used only in Visual Components). Each type of block has its own specific properties.

The block type is defined during creation and cannot be changed. If you need to change the block type, you will have to delete the block and create another block of the necessary type in exactly the same place:

  1. Create a Region object using the IEngine::CreateRegion method and copy the region of the block you need to replace with the help of the IRegion::CopyFrom method.
  2. Delete the old block from the layout by calling the ILayoutBlocks::DeleteAt method.
  3. Create a new block of the required type and add it into the collection of layout blocks using the AddNew method of the LayoutBlocks object. Pass the Region you copied from the old block as one of the required parameters.

Additional attributes

BackgroundColor

int, read-only

Specifies the background color of the block.

The int value is calculated from the RGB triplet using the formula: ( red value ) + (256 x green value ) + (65536 x blue value ), where red value is the first triplet component, green value is the second triplet component, blue value is the third triplet component. For example, the int value of the color white equals 16777215.

By default, the value of this property is -1, which means that the color is transparent.

BlockLayerType

BlockLayerTypeEnum, read-only

Specifies the layer of the block: background, foreground, or hidden. Blocks may be overlaid, for example, a text block may lay over a background picture block.

For RasterPictureBlock and VectorPictureBlock , you can change layer using the SetBlockLayerType method.

By default, the value of this property is BLT_Foreground.

Description

BSTR

Stores the description of the block.

By default, the value of this property is an empty string.

Name

BSTR

Stores the name of the block. It may be an arbitrary string.

By default, the value of this property is an empty string.

UserProperty

VARIANT

Allows you to associate some user-defined information of any type with an object of the Block type.

Methods

NameDescription
GetAsBarcodeBlockReturns the block as the BarcodeBlock object. If the block is not a barcode block, NULL is returned.
GetAsCheckmarkBlockReturns the block as the CheckmarkBlock object. If the block is not a checkmark block, NULL is returned.
GetAsCheckmarkGroupReturns the block as the CheckmarkGroup object. If the block is not a checkmark group block, NULL is returned.
GetAsRasterPictureBlockReturns the block as the RasterPictureBlock object. If the block is not a raster picture block, NULL is returned.
GetAsSeparatorBlockReturns the block as the SeparatorBlock object. If the block is not a separator block, NULL is returned.
GetAsSeparatorGroupReturns the block as the SeparatorGroup object. If the block is not a separator group block, NULL is returned.
GetAsTableBlockReturns the block as the TableBlock object. If the block is not a table block, NULL is returned.
GetAsTextBlockReturns the block as the TextBlock object. If the block is not a text block, NULL is returned.
GetAsVectorPictureBlockReturns the block as the VectorPictureBlock object. If the block is not a vector picture block, NULL is returned.
MoveOffsets block region by some vector.

Windows

Block

Linux and macOS

BlockLinuxMac Object Diagram

Output parameter

This object is the output parameter of the Item, AddNew methods of the LayoutBlocks object.

Samples

int picturesCount = 0;
int suspiciousCharsCount = 0;
int totalCharsCount = 0;
int barcodesCount = 0;
// Calculates the number of characters, suspicious characters, pictures and barcodes in a text
void computeStatisticsForBlock(FREngine.IBlock block)
{
 if (block.Type == FREngine.BlockTypeEnum.BT_Table)
 {
  FREngine.ITableBlock tableBlock = block.GetAsTableBlock();
  for (int iCell = 0; iCell < tableBlock.Cells.Count; iCell++)
  {
   computeStatisticsForBlock(tableBlock.Cells[iCell].Block);
  }
 }
 else if (block.Type == FREngine.BlockTypeEnum.BT_Text)
 {
  FREngine.ITextBlock textBlock = block.GetAsTextBlock();
  int paragraphsCount = textBlock.Text.Paragraphs.Count;
  for (int iPar = 0; iPar < paragraphsCount; iPar++)
  {
   FREngine.IParagraph par = textBlock.Text.Paragraphs[iPar];
   string text = par.Text;
   totalCharsCount += text.Length;
   FREngine.ICharParams charParams = engine.CreateCharParams();
   for (int iChar = 0; iChar < text.Length; iChar++)
   {
    par.GetCharParams(iChar, charParams);
    if (charParams.IsSuspicious)
    {
     suspiciousCharsCount++;
    }
   }
  }
 }
 else if (block.Type == FREngine.BlockTypeEnum.BT_RasterPicture || block.Type == FREngine.BlockTypeEnum.BT_VectorPicture)
 {
  picturesCount++;
 }
 else if (block.Type == FREngine.BlockTypeEnum.BT_Barcode)
 {
  barcodesCount++;
 }
}
The object is used in the following code samples:

See also

LayoutBlocks Working with Layout and Blocks Working with Properties