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) converts 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:
Pass OCR languages through CConvertOption.languages and set CConvertOption.language_count for each conversion task.
COCRLanguage languages[] = {e_CENGLISH};
CConvertOption option = CPDF_DefaultConvertOption();
option.enable_ocr = true;
option.languages = languages;
option.language_count = 1;
CPDF_StartPDFToWord(CPDF_TEXT("word.pdf"), CPDF_TEXT("password"), CPDF_TEXT("path/output.docx"), option, NULL);Supported C enum values include:
| Enum | Description |
|---|---|
e_CCHINESE | Chinese Simplified |
e_CCHINESE_TRA | Chinese Traditional |
e_CENGLISH | English |
e_CKOREAN | Korean |
e_CJAPANESE | Japanese |
e_CLATIN | Latin script languages |
e_CDEVANAGARI | Devanagari |
e_CCYRILLIC | Cyrillic |
e_CARABIC | Arabic |
e_CTAMIL | Tamil |
e_CTELUGU | Telugu |
e_CKANNADA | Kannada |
e_CTHAI | Thai |
e_CGREEK | Greek |
e_CEslav | Eslav |
e_CAUTO | Automatically select language |
Different OCR options can be selected according to actual needs:
e_CInvalidCharacter: Recognizes invalid or garbled characters in the PDF document through OCR, while normal characters are not processed by OCR.e_CScanPage: Recognizes scanned pages in the PDF document through OCR, while editable pages are not processed by OCR.e_CInvalidCharacterAndScanPage: Recognizes both invalid characters and scanned pages in the PDF document through OCR.e_CAll: Recognizes all pages and characters in the PDF document through OCR.When OCR is enabled, you can enable contain_page_background_image to preserve the original page background image of the PDF. 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, PowerPoint, HTML, CSV, RTF, TXT, JSON, and other formats.
CPDF_SetDocumentAIModel(CPDF_TEXT("path/documentai.model"), -1);
COCRLanguage languages[] = {e_CENGLISH};
CConvertOption option = CPDF_DefaultConvertOption();
option.enable_ocr = true;
option.languages = languages;
option.language_count = 1;
CPDF_StartPDFToWord(CPDF_TEXT("input.png"), CPDF_TEXT(""), CPDF_TEXT("path/output.docx"), option, NULL);