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.
ComPDF Conversion SDK supports converting PDF documents to OFD documents. Similar to searchable PDF, OFD conversion also supports OCR, page background preservation, and transparent text layers.
This format uses only the following options of ConvertOptions; the other options have no effect:
| Option | Default | Meaning |
|---|---|---|
enable_ocr | false | The text layer comes from OCR on the pages chosen by ocr_option; when off, it comes from the text of the PDF. Image input without OCR has no text layer. 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 of the text layer 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 size follows 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. |
enable_ai_layout | true | Only changes how the invisible text of pages not recognized by OCR is grouped, and the header and footer detection; the visible page image is not affected. |
formula_to_image | true | When on, the text of formulas found by AI layout analysis is removed from the invisible text layer (it can no longer be copied or searched); turn it off to keep it. The page image is unchanged. Only for pages not recognized by OCR, 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: sizes the page from the image resolution, matched to the nearest standard paper size; when off, one image pixel becomes one point. |
custom_page_width / custom_page_height | 0 | Image input only: exact page width and height in points (1 pt = 1/72 inch); both must be greater than 0. The image is fitted inside with white padding. Takes precedence over enable_auto_page_size. |
Example:
ConvertOptions opt;
opt.enable_ocr = true;
opt.enable_document_orientation_classification = true;
opt.output_document_per_page = true;
CPDFConversion::StartPDFToOfd("input.pdf", "password", "path/output.ofd", opt);transparent_text.enable_ocr is enabled, it is recommended to specify the OCR language through languages.LibraryManager::SetDocumentAIModel("path/documentai.model");
ConvertOptions opt;
opt.enable_ocr = true;
opt.languages = {OCRLanguage::e_English};
opt.contain_page_background_image = true;
opt.transparent_text = true;
CPDFConversion::StartPDFToOfd("scan.pdf", "password", "path/output.ofd", opt);