Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 11.4   11.5   12.0   12.1   12.2   12.3   12.4   12.5   13.0   13.1    Statistic    FMM    Blog  


Initializes tesseract.

Component Version macOS Windows Linux Server iOS SDK
OCR 2.9 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "OCR.Initialize"; Path; Lang { ; Options } )   More


Parameter Description Example Flags
Path The path to the folder where to find tessdata folder. $path
Lang The language to use. "eng"
Options For tessertact 4 or newer, pass here optional option list. Optional


Returns OK on success.


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:

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 and do initialization for their execution thread if needed before using OCR functions. But then each script can do OCR in parallel using multiple CPU cores.

To use tesseract 4.x, please use OCR.Load function to load the newer libraries.

Please notice that using data files for version 3 with library of version 4 (or other way around) will crash.

We intent to remove tesseract 3.x library from the plugin in summer 2022, so please move to loading the newer version.

This function requires a native path. Use Path.FileMakerPathToNativePath 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 functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.


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

set variable $databasePath to Get(FilePath)
set variable $databasePath to MBS("Path.FileMakerPathToNativePath"; $databasePath)
set variable $databasePath to Substitute ( $databasePath ; ".fp7" ; ".fmp12")
set variable $databaseName to Get(FileName) & ".fmp12"
set variable $path to Substitute ( $databasePath ; $databaseName ; "tessdata" )
set variable $r to 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") ≠ 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

Example Databases

Blog Entries

This function does not need a paid license.

Created 18th August 2014, last changed 6th May 2022

OCR.GetVariable - OCR.IsInitialized

💬 Ask a question or report a problem

Start Chat