Last active
June 16, 2021 12:38
-
-
Save aspose-com-gists/95b3d43a8cf031d0bb0bd4f229741b4a to your computer and use it in GitHub Desktop.
Convert Image to Word Document (DOCX) with OCR using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Convert Image to Word Document (DOCX) with OCR using C++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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