PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
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. The table model is only invoked for table regions reported by layout analysis whose detection confidence is below the trusted threshold; high-confidence native PDF tables bypass the model to save inference time.
Typical scenarios that benefit from Table Recognition:
Features that support Table Recognition:
enable_ai_layout = true, or implicitly when enable_ocr = true).enable_ai_table_recognition = false disables the table model entirely; detected table regions will then fall back to geometric reconstruction from the underlying page objects.LibraryManager::SetDocumentAIModelCount. See 3.2 Set DocumentAI Model.table_recognition_accuracy; see "Table Model Profile" below.Table Recognition provides two model profiles, selected per conversion task through ConvertOptions.table_recognition_accuracy (type TableRecognitionAccuracy):
| Profile | Description |
|---|---|
e_HighAccuracy (0) | Prioritizes recognition accuracy and may use more resources. The default behavior in 4.2.0 |
e_Balanced (1, default since 4.3.0) | Balances recognition accuracy, resource usage, and throughput |
documentai.model. The high-accuracy profile requires the table extension package table_legacy.model to be loaded as well (see 3.2 Set DocumentAI Model).table_recognition_accuracy.table_legacy.model), the conversion still succeeds, but tables are recognized with the rule-based method instead, so the result differs from that profile.LibraryManager::SetDocumentAIModel("path/documentai.model", -1);
LibraryManager::SetDocumentAIModel("path/table_legacy.model", -1);
ConvertOptions opt;
// Use the high-accuracy profile (requires table_legacy.model to be loaded).
opt.table_recognition_accuracy = TableRecognitionAccuracy::e_HighAccuracy;
CPDFConversion::StartPDFToWord("word.pdf", "password", "path/output.docx", opt);This sample demonstrates how to convert a PDF to a DOCX file with Table Recognition enabled.
// Set the DocumentAI model path.
LibraryManager::SetDocumentAIModel("path/documentai.model");
ConvertOptions opt;
// Layout analysis must be enabled for Table Recognition to take effect.
opt.enable_ai_layout = true;
// Enable AI table recognition (enabled by default; set to false to disable).
opt.enable_ai_table_recognition = true;
CPDFConversion::StartPDFToWord("word.pdf", "password", "path/output.docx", opt);