Overview
Table Recognition reconstructs the internal structure of tables detected during layout analysis, including rows, columns, merged cells, and cell boundaries, so that the converted document preserves the original tabular semantics instead of producing a flat grid of text fragments.
It is controlled by the independent option enable_ai_table_recognition, which is enabled by default in the helper in this guide. The table model is invoked for table regions detected by layout analysis.
Typical scenarios that benefit from Table Recognition:
- Borderless or partially bordered tables.
- Tables with merged header cells, multi-row headers, or spanning cells.
- Scanned tables processed by OCR.
Notice
- Table Recognition runs only when layout analysis is active, either through
enable_ai_layout = trueor implicitly throughenable_ocr = true. - You need to load the DocumentAI model before using Table Recognition, or plug in your own table model via callbacks described in 4.11 Use Custom AI Models via Callbacks.
- Set
enable_ai_table_recognition = falseto disable the table model. - The number of Table Recognition model instances can be tuned through the second parameter of
CPDF_SetDocumentAIModelCount.
Sample
c
CPDF_SetDocumentAIModel(CPDF_TEXT("path/documentai.model"), -1);
CConvertOption option = CPDF_DefaultConvertOption();
option.enable_ai_layout = true;
option.enable_ai_table_recognition = true;
CPDF_StartPDFToWord(CPDF_TEXT("word.pdf"), CPDF_TEXT("password"), CPDF_TEXT("path/output.docx"), option, NULL);