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 / Notes | 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 the options.languages for each conversion task, rather than through a separate global interface.
LibraryManager.setDocumentAIModel("path/model");
WordOptions opt = new WordOptions();
opt.setEnableOcr(true);
opt.setOcrLanguages(Arrays.asList(
OCRLanguage.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 containPageBackgroundImage 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.
LibraryManager.setDocumentAIModel("path/model");
WordOptions opt = new WordOptions();
opt.setEnableOcr(true);
opt.setOcrLanguages(Arrays.asList(
OCRLanguage.ENGLISH
));
// Supports jpg, jpeg, png, bmp, tiff 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.
LibraryManager.setDocumentAIModel("path/model");
WordOptions opt = new WordOptions();
opt.setEnableOcr(true);
opt.setOcrLanguages(Arrays.asList(
OCRLanguage.ENGLISH
));
CPDFConversion.startPDFToWord("word.pdf", "password", "path/output.docx", opt);