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.
OCR (Optical Character Recognition) is the process of converting images of typed, handwritten, or printed text into machine-encoded text.
OCR is commonly used for text recognition and extraction from the following types of documents:
The following features support OCR:
OCR Language Support of ComPDF Conversion SDK:
| Script / Notice | Language (Native) | Language (In English) |
|---|---|---|
| Latn; American | English | English |
| Latn; Canadian | Français canadien | French |
| Hans/Hant | 中文简体 | Chinese (Simplified) |
| Hans/Hant | 中文繁体 | Chinese (Traditional) |
| Jpan | 日本語 | Japanese |
| Kore | 한국어 | Korean |
| Latn | Deutsch | German |
| Latn | Српски (латиница) | Serbian (latin) |
| Latn | Occitan, lenga d'òc, provençal | Occitan |
| Latn | Dansk | Danish |
| Latn | Italiano | Italian |
| Latn; European | Español | Spanish |
| Latn; European | Português (Portugal) | Portuguese |
| Latn | Te reo Māori | Maori |
| Latn | Bahasa Melayu | Malay |
| Latn | Malti | Maltese |
| Latn | Nederlands | Dutch |
| Latn; Bokmål | Norsk | Norwegian |
| Latn | Polski | Polish |
| Latn | Română | Romanian |
| Latn | Slovenčina | Slovak |
| Latn | Slovenščina | Slovenian |
| Latn | shqip | Albanian |
| Latn | Svenska | Swedish |
| Latn | Swahili | Swahili |
| Latn | Wikang Tagalog | Tagalog |
| Latn | Türkçe | Turkish |
| Latn | oʻzbekcha | Uzbek |
| Latn | Tiếng Việt | Vietnamese |
| Latn | Afrikaans | Afrikaans |
| Latn | Azərbaycan | Azerbaijani |
| Latn | Bosanski | Bosnian |
| Latn | Čeština | Czech |
| Latn | Cymraeg | Welsh |
| Latn | Eesti keel | Estonian |
| Latn | Gaeilge | Irish |
| Latn | Hrvatski | Croatian |
| Latn | Magyar | Hungarian |
| Latn | Bahasa Indonesia | Indonesian |
| Latn | Íslenska | Icelandic |
| Latn | Kurdî | Kurdish |
| Latn | Lietuvių | Lithuanian |
| Latn | Latviešu | Latvian |
In the current mainline version, OCR languages should be passed through ConvertOptions.languages for each conversion task, rather than through a separate global interface.
ConvertOptions opt;
opt.enable_ocr = true;
opt.languages = {OCRLanguage::e_English};
CPDFConversion::StartPDFToWord("word.pdf", "password", "path/output.docx", opt);Different OCR options can be selected according to actual needs. Below are the currently supported OCR options.
When OCR is enabled, you can choose whether to enable the contain_page_background_image option. If this option is enabled, the original page background image of the PDF will be preserved. If it is disabled, the image result detected during page layout analysis will be retained.
The OCR function also supports converting input images into Word, Excel, Slides, HTML, CSV, RTF, TXT, JSON, and other formats. This sample demonstrates how to use the ComPDF OCR function to convert image files to a DOCX file.
// Set the DocumentAI model path.
LibraryManager::SetDocumentAIModel("path/documentai.model");
ConvertOptions opt;
// Enable OCR option.
opt.enable_ocr = true;
// Set the OCR language for this task.
opt.languages = {OCRLanguage::e_English};
// Supports jpg, jpeg, png, bmp, tiff, and webp formats.
CPDFConversion::StartPDFToWord("input.png", "", "path/output.docx", opt);This Sample demonstrates how to use the ComPDF OCR function to convert a PDF to DOCX file.
// Set the DocumentAI model path.
LibraryManager::SetDocumentAIModel("path/documentai.model");
ConvertOptions opt;
// Enable OCR option.
opt.enable_ocr = true;
opt.languages = {OCRLanguage::e_English};
CPDFConversion::StartPDFToWord("word.pdf", "password", "path/output.docx", opt);