> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How Component Synchronizer Works

<Warning>
  Visual Components are implemented in FRE for Windows.
</Warning>

[Component Synchronizer](/fine-reader/engine/visual-components-reference/supplementary-objects/componentsynchronizer) is a special component that implements an automatic reaction to different events in the Visual Components. You can connect several Visual Components to the Synchronizer, and they will work as a single application.

You do not need to use Component Synchronizer with the whole set of the components connected, but connect only those which you use. For example, you can connect to it only [Image Viewer](/fine-reader/engine/visual-components-reference/imageviewer) via the ImageViewer property and [Text Editor](/fine-reader/engine/visual-components-reference/texteditor) via the TextEditor property.

Component Synchronizer does not have a user interface. It does not use any internal features of the Visual Components, it uses only the COM API of the components. Component Synchronizer works as described below.

## When a component is connected to the Synchronizer through the API

If a component or an object is connected to Component Synchronizer through:

<Accordion title="ImageViewer property">
  In this case, the <strong>IComponentSynchronizer::ImageViewer</strong> property is set to the specified <strong>ImageViewer</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>IImageViewer::ZoomRectEnabled</strong></td>
        <td>True</td>
      </tr>

      <tr>
        <td><strong>IImageViewer::DocumentProcessingParams</strong></td>
        <td><strong>IComponentSynchronizer::DocumentProcessingParams</strong></td>
      </tr>

      <tr>
        <td><strong>IImageViewer::FRPage</strong></td>
        <td>The page in the <strong>IComponentSynchronizer::Document</strong> with the <strong>IComponentSynchronizer::PageIndex</strong> index</td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="ZoomViewer property">
  In this case, the <strong>IComponentSynchronizer::ZoomViewer</strong> property is set to the specified <strong>ZoomViewer</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>IZoomViewer::SymbolRectEnabled</strong></td>
        <td>True</td>
      </tr>

      <tr>
        <td><strong>IZoomViewer::DocumentProcessingParams</strong></td>
        <td><strong>IComponentSynchronizer::DocumentProcessingParams</strong></td>
      </tr>

      <tr>
        <td><strong>IZoomViewer::FRPage</strong></td>
        <td>The page in the <strong>IComponentSynchronizer::Document</strong> with the <strong>IComponentSynchronizer::PageIndex</strong> index</td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="TextEditor property">
  In this case, the <strong>IComponentSynchronizer::TextEditor</strong> property is set to the specified <strong>TextEditor</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>ITextEditor::SynthesisParamsForDocument</strong></td>
        <td>The value of the <strong>SynthesisParamsForDocument</strong> property of the <strong>IComponentSynchronizer::DocumentProcessingParams</strong> object</td>
      </tr>

      <tr>
        <td><strong>ITextEditor::FRPage</strong></td>
        <td>The page in the <strong>IComponentSynchronizer::Document</strong> with the <strong>IComponentSynchronizer::PageIndex</strong> index</td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="TextValidator property">
  In this case, the <strong>IComponentSynchronizer::TextValidator</strong> property is set to the specified <strong>TextValidator</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>ITextValidator::SynthesisParamsForDocument</strong></td>
        <td>The value of the <strong>SynthesisParamsForDocument</strong> property of the <strong>IComponentSynchronizer::DocumentProcessingParams</strong> object</td>
      </tr>

      <tr>
        <td><strong>ITextValidator::FRDocument</strong></td>
        <td><strong>IComponentSynchronizer::Document</strong></td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="DocumentViewer property">
  In this case, the IComponentSynchronizer::DocumentViewer property is set to the specified <strong>DocumentViewer</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>IDocumentViewer::FRDocument</strong></td>
        <td><strong>IComponentSynchronizer::Document</strong></td>
      </tr>

      <tr>
        <td><strong>IDocumentViewer::DocumentProcessingParams</strong></td>
        <td><strong>IComponentSynchronizer::DocumentProcessingParams</strong></td>
      </tr>

      <tr>
        <td><strong>IDocumentViewer::ActivePage</strong></td>
        <td>The page in the <strong>IComponentSynchronizer::Document</strong> with the <strong>IComponentSynchronizer::PageIndex</strong> index</td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="Document property">
  In this case, the <strong>IComponentSynchronizer::Document</strong> property is set to the specified <strong>FRDocument</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>IImageViewer::FRPage</strong><br /><strong>IZoomViewer::FRPage</strong><br /><strong>ITextEditor::FRPage</strong><br /><strong>IDocumentViewer::ActivePage</strong></td>
        <td>The first page in the <strong>IComponentSynchronizer::Document</strong></td>
      </tr>

      <tr>
        <td><strong>IComponentSynchronizer::PageIndex</strong></td>
        <td>0</td>
      </tr>

      <tr>
        <td><strong>IDocumentViewer::FRDocument</strong><br /><strong>ITextValidator::FRDocument</strong></td>
        <td><strong>IComponentSynchronizer::Document</strong></td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="DocumentProcessingParams property">
  In this case, the <strong>IComponentSynchronizer::DocumentProcessingParams</strong> property is set to the specified <strong>DocumentProcessingParams</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>IImageViewer::DocumentProcessingParams</strong><br /><strong>IZoomViewer::DocumentProcessingParams</strong><br /><strong>IDocumentViewer::DocumentProcessingParams</strong></td>
        <td><strong>IComponentSynchronizer::DocumentProcessingParams</strong></td>
      </tr>

      <tr>
        <td><strong>ITextEditor::SynthesisParamsForDocument</strong> <br /><strong>ITextValidator::SynthesisParamsForDocument</strong></td>
        <td>The value of the <strong>SynthesisParamsForDocument</strong> property of the <strong>IComponentSynchronizer::DocumentProcessingParams</strong> object</td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="PageIndex property">
  In this case, the <strong>IComponentSynchronizer::PageIndex</strong> property is set to the specified value, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td><strong>IImageViewer::FRPage</strong><br /><strong>IZoomViewer::FRPage</strong><br /><strong>ITextEditor::FRPage</strong><br /><strong>IDocumentViewer::ActivePage</strong></td>
        <td>The page in the <strong>IComponentSynchronizer::Document</strong> with the <strong>IComponentSynchronizer::PageIndex</strong> index</td>
      </tr>
    </tbody>
  </table>
</Accordion>

## When a connected component generates an event

Events of the connected Image Viewer:

<Accordion title="OnMouseButtonUp event">
  If Image Viewer generates the [OnMouseButtonUp](/fine-reader/engine/visual-components-reference/iinputevents/onmousebuttonup-method) event, Component Synchronizer performs the following operations:

  ```
  if( mouseButton == MBU_LeftButton && ZoomViewer != 0 ) {
   int documentX = 0;
   int documentY = 0;
   ImageViewer->ScreenToDocument( x, y, &documentX, &documentY );
   ZoomViewer->CenterOnDocumentPoint( documentX, documentY );
  }
  ```
</Accordion>

<Accordion title="OnBlockSelectionChanged event">
  If Image Viewer generates the [OnBlockSelectionChanged](/fine-reader/engine/visual-components-reference/iimageviewerevents/onblockselectionchanged-method) event, Component Synchronizer performs the following operations:

  ```
  if( selected == VARIANT_TRUE ) {
   if( textEditor != 0 ) {
    textEditor->ShowBlock( blockIndex, NotFound );
   }
  }
  ```
</Accordion>

<Accordion title="OnTableSelected event">
  If Image Viewer generates the [OnTableCellsSelected](/fine-reader/engine/visual-components-reference/iimageviewerevents/ontablecellsselected-method) event, Component Synchronizer calls the [ShowBlock](/fine-reader/engine/visual-components-reference/texteditor/showblock-method) method of the [TextEditor](/fine-reader/engine/visual-components-reference/texteditor) object with the selected block index and the lower right cell index.
</Accordion>

<Accordion title="OnAfterDblClick event">
  If Image Viewer generates the [OnAfterDblClick](/fine-reader/engine/visual-components-reference/iimageviewerevents/onafterdblclick-method) event, Component Synchronizer performs the following operations:

  ```
  if( textEditor != 0 ) {
   textEditor->ActivateOn( blockIndex, x, y );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged event">
  If Image Viewer generates the [OnActivePageChanged](/fine-reader/engine/visual-components-reference/iimageviewerevents/onactivepagechanged-method) event and the ZoomViewer, TextEditor, DocumentViewer properties of the ComponentSynchronizer object have already been set, the FRPage or ActivePage property of the corresponding component is set to the specified page of the document.
</Accordion>

<Accordion title="OnSelectTool event">
  If Image Viewer generates the [OnSelectTool](/fine-reader/engine/visual-components-reference/iimageviewerevents/onselecttool-method) event, Component Synchronizer performs the following operations:

  ```
  if( ZoomViewer == 0 ) {
   return;
  }
  IFRPagePtr curPage;
  ZoomViewer->get_FRPage( &curPage );
  if( curPage != 0 ) {
   ZoomViewer->put_ActiveTool( selectedTool );
  }
  ```
</Accordion>

<Accordion title="OnOptionsChanged event">
  If Image Viewer generates the [OnOptionsChanged](/fine-reader/engine/visual-components-reference/iimageviewerevents/onoptionschanged-method) event and the ZoomViewer, DocumentViewer, TextEditor, TextValidator properties of the ComponentSynchronizer object have already been set, the UpdateOptions method of the ZoomViewer, DocumentViewer, TextEditor, TextValidator objects is called.
</Accordion>

Events of the connected Zoom Viewer:

<Accordion title="OnVisibleDocumentAreaChanged event">
  If Zoom Viewer generates the [OnVisibleDocumentAreaChange](/fine-reader/engine/visual-components-reference/izoomviewerevents/onvisibledocumentareachange-method) event, Component Synchronizer performs the following operations:

  ```
  if( ImageViewer != 0 ) {
   ImageViewer->put_ZoomRect( visibleRect );
   if( isInFocus ) {
    ImageViewer->ShowDocumentArea( visibleRect );
   }
  }
  ```
</Accordion>

<Accordion title="OnBlockSelectionChanged event">
  If Zoom Viewer generates the [OnBlockSelectionChanged](/fine-reader/engine/visual-components-reference/izoomviewerevents/onblockselectionchanged-method) event, Component Synchronizer performs the following operations:

  ```
  if( selected == VARIANT_TRUE ) {
   if( textEditor != 0 ) {
    textEditor->ShowBlock( blockIndex, NotFound );
   }
  }
  ```
</Accordion>

<Accordion title="OnTableCellsSelected event">
  If Zoom Viewer generates the [OnTableCellsSelected](/fine-reader/engine/visual-components-reference/izoomviewerevents/ontablecellsselected-method) event, Component Synchronizer calls the ShowBlock method of the TextEditor object with the selected block index and the lower right cell index.
</Accordion>

<Accordion title="OnAfterDblClick event">
  If Zoom Viewer generates the [OnAfterDblClick](/fine-reader/engine/visual-components-reference/iimageviewerevents/onafterdblclick-method) event, Component Synchronizer performs the following operations:

  ```
  if( textEditor != 0 ) {
   textEditor->ActivateOn( blockIndex, x, y );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged event">
  If Zoom Viewer generates the [OnActivePageChanged](/fine-reader/engine/visual-components-reference/izoomviewerevents/onactivepagechanged-method) event and the ImageViewer, TextEditor, DocumentViewer properties of the ComponentSynchronizer object have already been set, the FRPage or ActivePage property of the corresponding component is set to the specified page of the document.
</Accordion>

<Accordion title="OnSelectTool event">
  If Zoom Viewer generates the [OnSelectTool](/fine-reader/engine/visual-components-reference/izoomviewerevents/onselecttool-method) event, Component Synchronizer performs the following operations:

  ```
  if( ImageViewer == 0 ) {
   return;
  }
  IFRPagePtr curPage;
  ImageViewer->get_FRPage( &curPage );
  if( curPage != 0 ) {
   ImageViewer->put_ActiveTool( selectedTool );
  }
  ```
</Accordion>

<Accordion title="OnOptionsChanged event">
  If Zoom Viewer generates the [OnOptionsChanged](/fine-reader/engine/visual-components-reference/izoomviewerevents/onoptionschanged-method) event and the ImageViewer, DocumentViewer, TextEditor, TextValidator properties of the ComponentSynchronizer object have already been set, the UpdateOptions method of the ImageViewer, DocumentViewer, TextEditor, TextValidator objects is called.
</Accordion>

Events of the connected Document Viewer:

<Accordion title="OnActivePageChanged event">
  If Document Viewer generates the [OnActivePageChanged](/fine-reader/engine/visual-components-reference/idocumentviewerevents/onactivepagechanged-method) event and the ImageViewer, ZoomViewer, TextEditor properties of the ComponentSynchronizer object have already been set, the FRPage property of the corresponding component is set to the specified page of the document.
</Accordion>

<Accordion title="OnDocumentChanged event">
  If Document Viewer generates the [OnDocumentChanged](/fine-reader/engine/visual-components-reference/idocumentviewerevents/ondocumentchanged-method) event and the ImageViewer, ZoomViewer, TextEditor, TextValidator properties of the ComponentSynchronizer object have already been set:

  * the FRDocument property of the TextValidator object is set to the new document
  * the FRPage property of the ImageViewer, ZoomViewer, and TextEditor objects and the ActivePage property of the DocumentViewer object are set to the first page of the new document
</Accordion>

<Accordion title="OnOptionsChanged event">
  If Document Viewer generates the [OnOptionsChanged](/fine-reader/engine/visual-components-reference/idocumentviewerevents/onoptionschanged-method) event and the ImageViewer, ZoomViewer, TextEditor, TextValidator properties of the ComponentSynchronizer object have already been set, the UpdateOptions method of the ImageViewer, ZoomViewer, TextEditor, TextValidator objects is called.
</Accordion>

Events of the connected Text Editor:

<Accordion title="OnEditorBlockChanged event">
  If Text Editor generates the [OnEditorBlockChanged](/fine-reader/engine/visual-components-reference/itexteditorevents/oneditorblockchanged-method) event, the ComponentSynchronizer performs the following operations:

  1. If the ImageViewer, ZoomViewer properties of the ComponentSynchronizer object have already been set, the SetSelectedBlocksIndices method of the ImageViewer and ZoomViewer object is called for the specified block.
  2. If it is a table block, the SetSelectedCells method of the ImageViewer and ZoomViewer object is called for the selected cell.
  3. Then the ShowDocumentArea method of the ImageViewer and ZoomViewer object is called.
</Accordion>

<Accordion title="OnSymbolSelected event">
  If Text Editor generates the [OnSymbolSelected](/fine-reader/engine/visual-components-reference/itexteditorevents/onsymbolselected-method) event, Component Synchronizer performs the following operations:

  ```
  if( ZoomViewer != 0 ) {
   ZoomViewer->put_SymbolRect( symbolRect );
  }
  if( ImageViewer != 0 ) {
   ImageViewer->ShowDocumentArea( symbolRect );
  }
  if( ZoomViewer != 0 ) {
   ZoomViewer->ShowDocumentArea( symbolRect );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged event">
  If Text Editor generates the [OnActivePageChanged](/fine-reader/engine/visual-components-reference/itexteditorevents/onactivepagechanged-method) event and the ImageViewer, ZoomViewer, DocumentViewer properties of the ComponentSynchronizer object have already been set, the FRPage or ActivePage property of the corresponding component is set to the specified page of the document.
</Accordion>

<Accordion title="OnOptionsChanged event">
  If Text Editor generates the [OnOptionsChanged](/fine-reader/engine/visual-components-reference/itexteditorevents/onoptionschanged-method) event and the ImageViewer, ZoomViewer, DocumentViewer, TextValidator properties of the ComponentSynchronizer object have already been set, the UpdateOptions method of the ImageViewer, ZoomViewer, DocumentViewer, TextValidator objects is called.
</Accordion>

Events of the connected Text Validator:

<Accordion title="OnSymbolSelected event">
  If Text Validator generates the [OnSymbolSelected](/fine-reader/engine/visual-components-reference/itextvalidatorevents/onsymbolselected-method) event, Component Synchronizer performs the following operations:

  ```
  if( ZoomViewer != 0 ) {
   ZoomViewer->put_SymbolRect( symbolRectangle );
  }
  ```
</Accordion>

<Accordion title="OnSelectionChanged event">
  If Text Validator generates the [OnSelectionChanged](/fine-reader/engine/visual-components-reference/itextvalidatorevents/onselectionchanged-method) event, Component Synchronizer performs the following operations:

  ```
  int symbolPos;
  IEditorPosition* nextPosition;
  position->get_Symbol( &symbolPos );
  nextPosition->put_Symbol( symbolPos + length );
  if( textEditor != 0 ) {
   textEditor->SetSelection( position, nextPosition );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged event">
  If Text Validator generates the [OnActivePageChanged](/fine-reader/engine/visual-components-reference/itextvalidatorevents/onactivepagechanged-method) event and the ImageViewer, ZoomViewer, TextEditor, DocumentViewer properties of the ComponentSynchronizer object have already been set, the FRPage or ActivePage property of the corresponding component is set to the specified page of the document.
</Accordion>

<Accordion title="OnDocumentChanged event">
  If Text Validator generates the [OnDocumentChanged](/fine-reader/engine/visual-components-reference/itextvalidatorevents/ondocumentchanged-method) event and the ImageViewer, ZoomViewer, TextEditor, DocumentViewer properties of the ComponentSynchronizer object have already been set:

  * the FRDocument property of the DocumentViewer object is set to the new document
  * the FRPage property of the ImageViewer, ZoomViewer, and TextEditor objects and the ActivePage property of the DocumentViewer object are set to the first page of the new document.
</Accordion>

<Accordion title="OnOptionsChanged event">
  If Text Validator generates the [OnOptionsChanged](/fine-reader/engine/visual-components-reference/itextvalidatorevents/onoptionschanged-method) event and the ImageViewer, ZoomViewer, TextEditor, DocumentViewer properties of the ComponentSynchronizer object have already been set, the UpdateOptions method of the ImageViewer, ZoomViewer, TextEditor, DocumentViewer objects is called.
</Accordion>

## See also

[ComponentSynchronizer](/fine-reader/engine/visual-components-reference/supplementary-objects/componentsynchronizer)
