Images and scanned documents may contain textual information that you might need to process further. For this, performing OCR operations on such images may prove to be helpful. You can extract text from such images and save it as a searchable PDF file. To that end, this article will teach you how to convert images to searchable PDF files using C++.
- C++ API for Converting Images to Searchable PDF Files
- Convert Image to Searchable PDF File using C++
- Convert Skewed Image to Searchable PDF File using C++
C++ API for Converting Images to Searchable PDF Files
Aspose.OCR for C++ is an optical character recognition API that can reliably perform OCR operations on images and scanned documents. The API also enables you to convert images to searchable PDFs. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.OCR.Cpp
Convert Image to Searchable PDF File using C++
Aspose.OCR for C++ provides you the ability to convert JPEG, BMP, and PNG images to searchable PDF files. To achieve this, please follow the steps given below:
- Prepare the buffer for the result.
- Set the value of RecognitionSettings.save_format struct member as file_format::pdf.
- Perform the OCR operation on the image and save the PDF file using the asposeocr_page_save(const char * image_path, const char * save_path, RecognitionSettings settings) method.
The following sample code shows how to create a searchable PDF file from an image using C++:
Convert Skewed Image to Searchable PDF File using C++
The API also provides the ability to perform OCR operations on skewed images. The following are the steps to convert a skewed image to a searchable PDF file:
- Prepare the buffer for the result.
- Calculate the skew angle of the image using the asposeocr_get_skew(const char * image_path) method.
- Set the value of RecognitionSettings.save_format struct member as file_format::pdf.
- Specify the skew angle using RecognitionSettings.skew struct member.
- Perform the OCR operation on the image and save the PDF file using the asposeocr_page_save(const char * image_path, const char * save_path, RecognitionSettings settings) method.
The following are the steps to convert a skewed image to a searchable PDF file using C++:
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to convert images to searchable PDF files using C++. With Aspose.OCR for C++ API, you can convert JPEG, BMP, and PNG images to PDF format. The API provides many additional features that you can explore in detail by visiting the official documentation. In case of any questions, please feel free to reach us on our free support forum.