OCR.Initialize
--------------

Initializes tesseract.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [OCR](component_OCR.md) | [2.9](newinversion29.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "OCR.Initialize"; Path; Lang { ; Options } ) 

**MBS**( **"OCR.Initialize";** /\* Initializes tesseract. \*/  
**$Path**; /\* The path to the folder where to find tessdata folder.  
Must end with tessdata as folder name.  
  
Can be empty if tesseract libraries know where their files are. \*/   
**$Lang**; /\* The language to use.e.g. "eng" \*/   
**$Options**) /\* Optional; For tessertact 4 or newer, pass here optional option list. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | The path to the folder where to find tessdata folder.   Must end with tessdata as folder name.      Can be empty if tesseract libraries know where their files are. | $path |  |
| Lang | The language to use. | "eng" |  |
| Options | For tessertact 4 or newer, pass here optional option list. |  | Optional |

### Result

Returns OK on success.

### Description

Initializes tesseract.   
Pass path to parent folder of tessdata folder and language you need.  
The language is (usually) an ISO 639-3 string.  
To use multiple languages, please concat them with plus sign: e.g. "eng+deu"  
  
You find our language files archive here:  
<https://www.monkeybreadsoftware.com/filemaker/files/Libs/>  
  
The tessdata folder may need to contain additional files for some languages. If those are missing, the tesseract engine likes to abort the process.  
  
Starting with version 11.2 of MBS Plugin, the initialization is per thread. Scripts running on FileMaker server may need to check [OCR.IsInitialized](OCRIsInitialized.md) and do initialization for their execution thread if needed before using [OCR](component_OCR.md) functions. But then each script can do OCR in parallel using multiple CPU cores.  
  
To use tesseract 4.x, please use [OCR.Load](OCRLoad.md) function to load the newer libraries.  
  
Please notice that using data files for version 3 with library of version 4 or 5 (or other way around) will crash.  
  
We intent to removed tesseract 3.x library from the plugin in version 15.5, so please move to loading the newer version.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Initialize with tessdata folder in same folder as database for english:

 Set Variable \[ $databasePath ; Value: Get(FilePath) \]  
Set Variable \[ $databasePath ; Value: MBS ("[Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)"; $databasePath ) \]  
Set Variable \[ $databasePath ; Value: Substitute ( $databasePath ; ".fp7" ; ".fmp12") \]  
Set Variable \[ $databaseName ; Value: Get(FileName) &amp; ".fmp12" \]  
Set Variable \[ $path ; Value: Substitute ( $databasePath ; $databaseName ; "tessdata" ) \]  
Set Variable \[ $r ; Value: MBS ( "OCR.Initialize"; $path ; "eng") \]  
Initialize on Server with tessdata in Server folder:

 MBS ( "OCR.Initialize"; "/Library/FileMaker Server/"; "eng")  
Initialize on demand:

 If \[MBS ("[OCR.IsInitialized](OCRIsInitialized.md)") ≠ 1\]  
 Set Variable \[$r ; Value:MBS ( "OCR.Initialize"; "/Library/FileMaker Server/"; "eng")\]  
End If  
Initialize with hard coded path:

 Set Variable \[ $path ; Value: "/Users/cs/Tesseract/tesseract4/tessdata" \]   
Set Variable \[ $r ; Value: MBS ( "OCR.Initialize"; $path ; "eng") \]  
Initialize for chinese:

 Set Variable \[ $r ; Value: MBS ( "OCR.Initialize"; $path ; "chi\_sim") \]  
### See also

- [Java.Initialize](JavaInitialize.md)
- [OCR.GetText](OCRGetText.md)
- [OCR.GetTextWithCoordinates](OCRGetTextWithCoordinates.md)
- [OCR.IsInitialized](OCRIsInitialized.md)
- [OCR.Load](OCRLoad.md)
- [OCR.RenderPDF](OCRRenderPDF.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [TAPI.Initialize](TAPIInitialize.md)
- [WIA.Initialize](WIAInitialize.md)
- [XL.Initialize](XLInitialize.md)

### Example Databases

- [OCR/OCR with DynaPDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/OCR/OCR%20with%20DynaPDF.shtml#1ScriptAnchor_)
- [OCR/OCR](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/OCR/OCR.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin 16.1 News](https://www.mbsplugins.de/archive/2026-03-31/MBS_FileMaker_Plugin_161_News/monkeybreadsoftware_blog_filemaker)
- [Installing and Loading Tesseract OCR with MBS Plugin](https://www.mbsplugins.de/archive/2025-10-29/Installing_and_Loading_Tessera/monkeybreadsoftware_blog_filemaker)
- [Introducing Tesseract 4 to FileMaker](https://www.mbsplugins.de/archive/2021-06-29/Introducing_Tesseract_4_to_Fil/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th August 2014 , last changed 25th February 2026

  
[OCR.GetVariable](OCRGetVariable.md) - [OCR.IsInitialized](OCRIsInitialized.md)

[HTML Version](OCRInitialize.shtml)