Last active
June 14, 2021 17:42
-
-
Save aspose-com-gists/782401e51497cec4542317a0b9e4e57f to your computer and use it in GitHub Desktop.
Convert Image to Searchable PDF 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 Searchable PDF 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.language_alphabet = language::eng; | |
settings.save_format = file_format::pdf; | |
// Perform the OCR operation and save the output file. | |
asposeocr_page_save(image_path.c_str(), "OutputDirectory\\ImageToPDF.pdf", 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.language_alphabet = language::eng; | |
settings.save_format = file_format::pdf; | |
settings.skew = angle; | |
// Perform the OCR operation and save the output file. | |
asposeocr_page_save(image_path.c_str(), "OutputDirectory\\SkewedImageToPDF.pdf", settings); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment