Skip to content
DemoFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Table Recognition ​

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 EnableAiTableRecognition, 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:

  • Borderless or partially bordered tables, where ruling lines alone cannot describe the structure.
  • Tables with merged header cells, multi-row headers, or spanning cells, such as financial statements, lab reports, and invoices.
  • Scanned tables processed by OCR, where geometric reconstruction is required before cell-level data extraction.

Features that support Table Recognition:

  • PDF to Word
  • PDF to Excel
  • PDF to PowerPoint (Slides)
  • PDF to HTML
  • PDF to RTF
  • PDF to CSV
  • Extract PDF to JSON
  • Extract PDF to Markdown

Notice ​

  • Table Recognition runs only when layout analysis is active (i.e. EnableAiLayout = true, or implicitly when EnableOCR = true).
  • You need to load the DocumentAI model before using Table Recognition, or plug in your own table model via the callbacks described in 3.12 Use Custom AI Models via Callbacks.
  • Setting EnableAiTableRecognition = false disables the table model entirely; detected table regions will then fall back to geometric reconstruction from the underlying page objects.
  • The number of Table Recognition model instances can be tuned via the second parameter of LibraryManager.SetDocumentAIModelCount. See 3.2 Set DocumentAI Model.

Table Model Profile ​

Table recognition provides two model profiles, selected for each conversion task through WordOptions.TableRecognitionAccuracy:

ProfileValueDescription
TableRecognitionAccuracy.e_HighAccuracy0Prioritizes recognition accuracy and may use more resources. The default behavior of 4.2.0.
TableRecognitionAccuracy.Balanced1Balances recognition accuracy, resource usage, and throughput. The default since 4.3.0.

Important: since 4.3.0 the default profile changes from high accuracy to balanced. Without any code change, the table recognition results and resource usage after upgrading differ from 4.2.0.

  • The balanced profile only needs the base model documentai.model shipped in the SDK package.
  • The high-accuracy profile requires table_legacy.model to be loaded additionally (see 3.2 Set DocumentAI Model for the download address).
  • Models of both profiles can be loaded at the same time, and each conversion task uses the one given by its TableRecognitionAccuracy.
  • If the requested profile has no corresponding model (for example, the high-accuracy profile without table_legacy.model), the conversion still succeeds, but tables are recognized with the rule-based method instead, so the result differs from that profile.
  • A profile name does not guarantee better results for every document.
  • Currently the .NET wrapper provides this option on WordOptions; the option classes of the other formats use the default balanced profile.
c#
LibraryManager.SetDocumentAIModel("path/documentai.model");
// The high-accuracy profile needs the table extension package to be loaded as well.
LibraryManager.SetDocumentAIModel("path/table_legacy.model");

WordOptions wordOptions = new WordOptions();
wordOptions.EnableAiLayout = true;
wordOptions.EnableAiTableRecognition = true;
wordOptions.TableRecognitionAccuracy = TableRecognitionAccuracy.e_HighAccuracy;

Sample ​

This sample demonstrates how to convert a PDF to a DOCX file with Table Recognition enabled.

c#
string inputFilePath = "***";
string password = "***";
string outputFileName = "***";
WordOptions wordOptions = new WordOptions();
// Layout analysis must be enabled for Table Recognition to take effect.
wordOptions.EnableAiLayout = true;
// Enable AI table recognition (enabled by default; set to false to disable).
wordOptions.EnableAiTableRecognition = true;
ErrorCode error = CPDFConversion.StartPDFToWord(inputFilePath, password, outputFileName, wordOptions);