Foxit PDF SDK

Public Types | Public Member Functions | List of all members
foxit::addon::ocr::OCR Class Reference
Inheritance diagram for foxit::addon::ocr::OCR:

## Public Types
enum | OCRConvertFormat { e_OCRConvertFormatDOCX = 0, e_OCRConvertFormatDOC = 1, e_OCRConvertFormatRTF = 2, e_OCRConvertFormatXLSX = 3, e_OCRConvertFormatXLS = 4, e_OCRConvertFormatPPTX = 5, e_OCRConvertFormatHTML = 6 }
| Enumeration for format used for OCR converting. More...

## Public Member Functions
| OCR ()
| Constructor.
| OCR (const OCR &other)
| Constructor, with another ocr object. More...
| ~OCR ()
| Destructor.
OCRSuspectInfoArray | GetOCRSuspectsInfo (pdf::PDFDoc ocred_pdf_doc)
| Get OCR suspicious information. More...
bool | IsEmpty () const
| Check whether current object is empty or not. More...
void | OCRConvertTo (OCRConvertFormat format, const wchar_t *src_pdf_path, const wchar_t *password, const wchar_t *saved_file_path, common::Range page_range, bool is_retain_flowing_text, OCRProgressCallback *callback=0)
| OCR the PDF document and convert it to a specified format document. More...
void | OCRConvertTo (OCRConvertFormat format, const wchar_t *src_pdf_path, const wchar_t *password, const wchar_t *saved_file_path, common::Range page_range, bool is_retain_flowing_text, const OCRConfig &config, OCRProgressCallback *callback=0)
| OCR the PDF document and convert it to a specified format document. More...
void | OCRPDFDocument (pdf::PDFDoc pdf_doc, bool is_editable, OCRProgressCallback *callback=0)
| OCR each page of a PDF document. More...
void | OCRPDFDocument (pdf::PDFDoc pdf_doc, bool is_editable, const OCRConfig &config, OCRProgressCallback *callback=0)
| OCR each page of a PDF document. More...
void | OCRPDFDocuments (const ocr::OCRSettingDataArray &settingdata_array, OCRProgressCallback *callback=0)
| OCR multiple pages of multiple PDF documents. More...
void | OCRPDFPage (pdf::PDFPage pdf_page, bool is_editable, OCRProgressCallback *callback=0)
| OCR a PDF page. More...
void | OCRPDFPage (pdf::PDFPage pdf_page, bool is_editable, const OCRConfig &config, OCRProgressCallback *callback=0)
| OCR a PDF page. More...
bool | operator != (const OCR &other) const
| Not equal operator. More...
OCR & | operator= (const OCR &other)
| Assign operator. More...
bool | operator== (const OCR &other) const
| Equal operator. More...
Public Member Functions inherited from foxit::Base
FS_HANDLE | Handle () const
| Get the handle of current object. More...

## Detailed Description

This class is used to do OCR for a PDF page or a PDF document. Please ensure OCR engine has been initialized before using this class.

See also
  OCREngine

## Member Enumeration Documentation

## ◆ OCRConvertFormat

enum foxit::addon::ocr::OCR::OCRConvertFormat

Enumeration for format used for OCR converting.

Values of this enumeration should be used alone.

Enumerator
e_OCRConvertFormatDOCX | OCR convert format: DOCX.
e_OCRConvertFormatDOC | OCR convert format: DOC.
e_OCRConvertFormatRTF | OCR convert format: RTF.
e_OCRConvertFormatXLSX | OCR convert format: XLSX.
e_OCRConvertFormatXLS | OCR convert format: XLS.
e_OCRConvertFormatPPTX | OCR convert format: PPTX.
e_OCRConvertFormatHTML | OCR convert format: HTML.

## Constructor & Destructor Documentation

## ◆ OCR()

foxit::addon::ocr::OCR::OCR | ( | const OCR & | other | ) |

Constructor, with another ocr object.

Parameters

  [in] | other | Another ocr object.

## Member Function Documentation

## ◆ GetOCRSuspectsInfo()

OCRSuspectInfoArray foxit::addon::ocr::OCR::GetOCRSuspectsInfo | ( | pdf::PDFDoc | ocred_pdf_doc | ) |

Get OCR suspicious information.

The parameter ocred_pdf_doc is a valid PDF document that should have been ocred.

Parameters

  [in] | ocred_pdf_doc | A valid PDF document object.

Returns
  An array of OCRSuspectInfo objects, If its value is empty, that means the document OCR has no suspicious information.

## ◆ IsEmpty()

bool foxit::addon::ocr::OCR::IsEmpty | ( |  | ) | const

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
  true means current object is empty, while false means not.

## ◆ OCRConvertTo() [1/2]

void foxit::addon::ocr::OCR::OCRConvertTo | ( | OCRConvertFormat | format,
|  | const wchar_t * | src_pdf_path,
|  | const wchar_t * | password,
|  | const wchar_t * | saved_file_path,
|  | common::Range | page_range,
|  | bool | is_retain_flowing_text,
|  | OCRProgressCallback * | callback = `0`
| ) |  |

OCR the PDF document and convert it to a specified format document.

Parameters

  [in] | format | The format of the document to convert. Please refer to values starting from OCR::e_OCRConvertFormatDOCX and this should be one of these values.
  [in] | src_pdf_path | The source PDF file path.This should not be an empty string.
  [in] | password | The password of the source PDF file. If the PDF file is not encrypted, this should be an empty string.
  [in] | saved_file_path | The path of the file to save. This should not be an empty string.
  [in] | page_range | The range of pages that need to be converted. If this is an empty range, that means to convert each page of the PDF document.
  [in] | is_retain_flowing_text | true means the generated document will retain flowing text, the text may be reformatted and page breaks cannot be guaranteed to be retained. false means the generated document will retain original page layout. This parameter is only useful for the following format types: OCR::e_OCRConvertFormatRTF, OCR::e_OCRConvertFormatDOC, OCR::e_OCRConvertFormatDOCX. Default value: true.
  [in] | callback | A customized progress callback which is implemented based on callback class OCRProgressCallback. NULL means not to receive progress notification.

Returns
  None.

## ◆ OCRConvertTo() [2/2]

void foxit::addon::ocr::OCR::OCRConvertTo | ( | OCRConvertFormat | format,
|  | const wchar_t * | src_pdf_path,
|  | const wchar_t * | password,
|  | const wchar_t * | saved_file_path,
|  | common::Range | page_range,
|  | bool | is_retain_flowing_text,
|  | const OCRConfig & | config,
|  | OCRProgressCallback * | callback = `0`
| ) |  |

OCR the PDF document and convert it to a specified format document.

Parameters

  [in] | format | The format of the document to convert. Please refer to values starting from OCR::e_OCRConvertFormatDOCX and this should be one of these values.
  [in] | src_pdf_path | The source PDF file path.This should not be an empty string.
  [in] | password | The password of the source PDF file. If the PDF file is not encrypted, this should be an empty string.
  [in] | saved_file_path | The path of the file to save. This should not be an empty string.
  [in] | page_range | The range of pages that need to be converted. If this is an empty range, that means to convert each page of the PDF document.
  [in] | is_retain_flowing_text | true means the generated document will retain flowing text, the text may be reformatted and page breaks cannot be guaranteed to be retained. false means the generated document will retain original page layout. This parameter is only useful for the following format types: OCR::e_OCRConvertFormatRTF, OCR::e_OCRConvertFormatDOC, OCR::e_OCRConvertFormatDOCX. Default value: true.
  [in] | config | The OCRConfig object.
  [in] | callback | A customized progress callback which is implemented based on callback class OCRProgressCallback. NULL means not to receive progress notification.

Returns
  None.

## ◆ OCRPDFDocument() [1/2]

void foxit::addon::ocr::OCR::OCRPDFDocument | ( | pdf::PDFDoc | pdf_doc,
|  | bool | is_editable,
|  | OCRProgressCallback * | callback = `0`
| ) |  |

OCR each page of a PDF document.

After this function succeeds, the PDF page content may be changed. It is better to parse or re-parse PDF pages in the input PDF document before using these pages.

Parameters

  [in] | pdf_doc | A valid PDF document object.
  [in] | is_editable | true means the OCR result is editable. false means the OCR result can only be searched but not be edited.
  [in] | callback | A customized progress callback which is implemented based on callback class OCRProgressCallback. NULL means not to receive progress notification.

Returns
  None.

## ◆ OCRPDFDocument() [2/2]

void foxit::addon::ocr::OCR::OCRPDFDocument | ( | pdf::PDFDoc | pdf_doc,
|  | bool | is_editable,
|  | const OCRConfig & | config,
|  | OCRProgressCallback * | callback = `0`
| ) |  |

OCR each page of a PDF document.

After this function succeeds, the PDF page content may be changed. It is better to parse or re-parse PDF pages in the input PDF document before using these pages.

Parameters

  [in] | pdf_doc | A valid PDF document object.
  [in] | is_editable | true means the OCR result is editable. false means the OCR result can only be searched but not be edited.
  [in] | config | The OCRConfig.
  [in] | callback | A customized progress callback which is implemented based on callback class OCRProgressCallback. NULL means not to receive progress notification.

Returns
  None.

## ◆ OCRPDFDocuments()

void foxit::addon::ocr::OCR::OCRPDFDocuments | ( | const ocr::OCRSettingDataArray & | settingdata_array,
|  | OCRProgressCallback * | callback = `0`
| ) |  |

OCR multiple pages of multiple PDF documents.

This function can be used to batch process multiple documents or pages. Users can set documents and page ranges via OCRSettingDataArray. The time performance of this function will be better than calling OCR::OCRPDFDocument or OCR::OCRPDFPage multiple times when dealing with a large number of documents or pages. After successful execution, the page content may be changed, it is better to parse or re-parse the PDF pages before using these pages.

Parameters

  [in] | settingdata_array | An array of OCRSettingData objects, if the parameter page_range of OCRSettingData object is empty, that means OCR each page of the PDF document.
  [in] | callback | A customized progress callback which is implemented based on callback class OCRProgressCallback. NULL means not to receive progress notification.

Returns
  None.

## ◆ OCRPDFPage() [1/2]

void foxit::addon::ocr::OCR::OCRPDFPage | ( | pdf::PDFPage | pdf_page,
|  | bool | is_editable,
|  | OCRProgressCallback * | callback = `0`
| ) |  |

OCR a PDF page.

After this function succeeds, the PDF page content may be changed and the input PDF page is recommended to be re-parsed.

Parameters

  [in] | pdf_page | A valid PDF page object. This PDF page should have been parsed.
  [in] | is_editable | true means the OCR result is editable. false means the OCR result can only be searched but not be edit.
  [in] | callback | A customized progress callback which is implemented based on callback class OCRProgressCallback. NULL means not to receive progress notification.

Returns
  None.

## ◆ OCRPDFPage() [2/2]

void foxit::addon::ocr::OCR::OCRPDFPage | ( | pdf::PDFPage | pdf_page,
|  | bool | is_editable,
|  | const OCRConfig & | config,
|  | OCRProgressCallback * | callback = `0`
| ) |  |

OCR a PDF page.

After this function succeeds, the PDF page content may be changed and the input PDF page is recommended to be re-parsed.

Parameters

  [in] | pdf_page | A valid PDF page object. This PDF page should have been parsed.
  [in] | is_editable | true means the OCR result is editable. false means the OCR result can only be searched but not be edited.
  [in] | config | The OCRConfig.
  [in] | callback | A customized progress callback which is implemented based on callback class OCRProgressCallback. NULL means not to receive progress notification.

Returns
  None.

## ◆ operator !=()

bool foxit::addon::ocr::OCR::operator != | ( | const OCR & | other | ) | const

Not equal operator.

Parameters

  [in] | other | Another ocr object. This function will check if current object is not equal to this one.

Returns
  true means not equal, while false means equal.

## ◆ operator=()

OCR& foxit::addon::ocr::OCR::operator= | ( | const OCR & | other | ) |

Assign operator.

Parameters

  [in] | other | Another ocr object, whose value would be assigned to current object.

Returns
  Reference to current object itself.

## ◆ operator==()

bool foxit::addon::ocr::OCR::operator== | ( | const OCR & | other | ) | const

Equal operator.

Parameters

  [in] | other | Another ocr object. This function will check if current object is equal to this one.

Returns
  true means equal, while false means not equal.