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.
Extract text, tables and images from PDF documents to Json file.
This format uses only the following options of ConvertOptions; the other options have no effect:
| Option | Default | Meaning |
|---|---|---|
json_contain_table | true | On: each table is output once as an HTML table with the row, column, span and text of every cell; off: the text of each cell is output as a separate text item of the page content. |
contain_image | true | On: the output is a .zip that holds the JSON, the page renderings and the image items; off: a plain .json without image items. With enable_ocr and enable_ai_layout on, it also drops the OCR text inside image regions found by AI layout analysis. |
enable_ai_layout | true | Gives the object types (title, list, table, header, footer, ...), the grouping, the reading order and the table detection. Ignored if the license does not include AI layout analysis. |
enable_ai_table_recognition | true | Recognizes the structure of tables with the table model; when off, the table structure is rebuilt from the ruling lines. Only applies to tables found by AI layout analysis (enable_ai_layout on). |
table_recognition_accuracy | TableRecognitionAccuracy::e_Balanced | Table model: TableRecognitionAccuracy::e_Balanced uses the base documentai.model, TableRecognitionAccuracy::e_HighAccuracy uses the table_legacy.model package. Only takes effect when AI table recognition runs with the built-in table model. If the model of the requested accuracy is not loaded, the conversion still succeeds and tables fall back to rule-based recognition. |
enable_ocr | false | Recognizes text with OCR on the pages chosen by ocr_option. Without OCR, image input gives only an image item (if contain_image is on) and no text. Ignored if the license does not include OCR. |
ocr_option | OCROption::e_All | Which content OCR handles: OCROption::e_All every page; OCROption::e_ScanPage only image (scanned) pages; OCROption::e_InvalidCharacter re-recognizes unreadable characters on the other pages; OCROption::e_InvalidCharacterAndScanPage both. Only takes effect when enable_ocr is on. |
languages / language_count | language_count = 0 | OCR recognition languages; when no language is given, English is used. Only takes effect when enable_ocr is on. |
enable_document_orientation_classification | false | Turns the page image upright before OCR; the page width, height and coordinates follow the rotation. Only takes effect when enable_ocr is on. |
enable_document_dewarp | false | Flattens curved or warped page photos before OCR. Only takes effect when enable_ocr is on. |
page_ranges | Empty | Pages to convert, e.g. "1-3,5,7-9"; empty converts every page. For multi-frame image input it selects the frames. |
contain_annotation | true | Outputs the appearance of annotations as image items. Only for PDF pages not recognized by OCR, and only when contain_image is on. |
formula_to_image | true | When on, formulas found by AI layout analysis become text items with empty text; turn it off to keep the formula text. Only applies with enable_ai_layout on. |
output_document_per_page | false | Writes one file per page instead of one document. The files are named after the input file plus the page number and are written to the folder of the output path; the file name in the output path is not used. |
enable_auto_page_size | false | Image input only: the page width, height and all positions use the page size from the image resolution, matched to the nearest standard paper size. |
custom_page_width / custom_page_height | 0 | Image input only: the page width, height and all positions use this exact page size in points; both must be greater than 0. Takes precedence over enable_auto_page_size. |
Example:
ConvertOptions opt;
opt.json_contain_table = false;
opt.contain_image = false;
CPDFConversion::StartPDFToJson("input.pdf", "password", "path/output.json", opt);Commonly, tables can be divided into two categories: standard tables and non-standard tables. The specific definitions are as follows:


ComPDF Conversion SDK supports the option json_contain_table, when enabled, will extract table content from PDFs and output the table structure; otherwise, table content will be treated as regular text.
Full sample code which illustrates the text extraction capabilities.
ConvertOptions opt;
// Extract PDF to JSON.
CPDFConversion::StartPDFToJson("json.pdf", "password", "path/output.json", opt);