Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/95b3d43a8cf031d0bb0bd4f229741b4a to your computer and use it in GitHub Desktop.
Save aspose-com-gists/95b3d43a8cf031d0bb0bd4f229741b4a to your computer and use it in GitHub Desktop.
Convert Image to Word Document (DOCX) with OCR using C++
Convert Image to Word Document (DOCX) with OCR using C++
// Source file path
std::string image_path = "SourceDirectory\\sample.png";
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t))
const size_t len = 4096;
wchar_t buffer[len] = { 0 };
// Set the recognition settings
RecognitionSettings settings;
settings.save_format = file_format::docx;
// Perform the OCR operation and save the output file.
asposeocr_page_save(image_path.c_str(), "OutputDirectory\\ImageToDocx.Docx", settings);
// Source file path
std::string image_path = "SourceDirectory\\skewSample.png";
// Prepare buffer for result (in symbols, len_byte = len * sizeof(wchar_t))
const size_t len = 4096;
wchar_t buffer[len] = { 0 };
// Calculate skew angle
std::double_t angle = asposeocr_get_skew(image_path.c_str());
// Set the recognition settings
RecognitionSettings settings;
settings.save_format = file_format::docx;
settings.skew = angle;
// Perform the OCR operation and save the output file.
asposeocr_page_save(image_path.c_str(), "OutputDirectory\\SkewedImageToDocx.docx", settings);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment