- 使用 C++ 将图像转换为 Word 文档
- 使用 C++ 将倾斜图像转换为 Word 文档

使用 C++ 将图像转换为 Word 文档
- 为结果准备缓冲区。
- 将RecognitionSettings.save_format结构成员的值设置为file_format::docx。
- 对图片进行OCR操作,使用asposeocr_page_save(const char * image_path, const char * save_path, RecognitionSettings settings)方法保存Word文件。
以下示例代码显示了如何使用 C++ 将图像转换为 Word 文档:
// Source file pathstd::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 settingsRecognitionSettings 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);

使用 C++ 将倾斜图像转换为 Word 文档
图像和扫描的文档有时会倾斜。使用 Aspose.OCR for C++ API,您可以对倾斜的图像执行 OCR。以下是将倾斜图像转换为 Word 文档的步骤:
- 为结果准备缓冲区。
- 使用asposeocr_get_skew(const char * image_path) 方法计算图像的倾斜角度 。
- 将RecognitionSettings.save_format 结构成员的值设置 为 file_format::docx。
- 使用RecognitionSettings.skew 结构成员指定倾斜角度 。
- 对图片进行OCR操作,使用asposeocr_page_save(const char * image_path, const char * save_path, RecognitionSettings settings) 方法保存Word文件 。
以下示例代码显示了如何使用 C++ 将倾斜图像转换为 Word 文档:
// Source file pathstd::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 anglestd::double_t angle = asposeocr_get_skew(image_path.c_str());// Set the recognition settingsRecognitionSettings 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);

如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。
如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!