Skip to content
ComPDF
DemoFAQ

Set DocumentAI Model

Overview

Before using OCR, Layout Analysis, Table Recognition you need to set the DocumentAI model path first.

SetDocumentAIModel supports an optional gpu_id parameter used to specify the GPU device index for the AI model. When gpu_id is -1, GPU acceleration is disabled.

Set AI Model Instance Count

If you need to control the number of Layout Analysis and Table Recognition model instances, call SetDocumentAIModelCount:

c#
// The first parameter is the number of Layout Analysis model instances,
// the second is the number of Table Recognition model instances.
LibraryManager.SetDocumentAIModelCount(1, 1);

If this interface is not called, the default model instance count is 1 for both.

Sample

c#
// Set the OCR model.
string modelPath = "***";
LibraryManager.SetDocumentAIModel(modelPath);

Use Your Own AI Engine (SDK v4.1.0+)

This option is available only in SDK v4.1.0 or later. If you prefer to run OCR, Layout Analysis, or Table Recognition with your own model or a third-party service instead of the bundled DocumentAI model, the SDK exposes callback hooks on ConvertCallback that let you supply the results as JSON. See 3.11 Use Custom AI Models via Callbacks for details. When all three capabilities you need are covered by your own callbacks, SetDocumentAIModel does not have to be called.