ComPDFKit Conversion SDK 1.8.1: OCR Plugin

Updates | PDF Conversion SDK · OCR Mon. 18 Sep. 2023

Previously, numerous buddies reported that after integrating the ComPDFKit Conversion SDK, the addition of the OCR function significantly increased the APP's size.

 

Many PDF reading software on the market, such as Adobe Acrobat, have already taken steps to lead the way. They will pop up a prompt when users need to use OCR, informing users that they need to download an additional OCR plugin. This design effectively reduces the size of the application and significantly improves the user experience.



Modular OCR Feature Advantages

 

In the new version, we have made the OCR module into a plugin and added an interface for manually setting the OCR module and model. This allows customers to integrate the ComPDFKit OCR function into their own app in the form of a plugin, ensuring the provision of OCR-enabled conversion, and improving conversion results (especially for documents with images or scanned files). Besides, the integration of the modular OCR feature has the following advantages:

 

         - Flexibility: The plugin feature of the OCR function allows customers to choose whether to integrate OCR into their own app, greatly enhancing the application's flexibility. 

         - Customization: With the provision of an interface for manually setting the OCR module and model, customers can customize the OCR function according to their own needs. 

         - Suitable for complex PDF document conversion: The OCR module can provide a text recognition function, effectively improving the conversion results and accuracy of documents with images or scanned files. 

         - Provide additional features: With the OCR function, customers' conversion app can not only complete basic file conversion functions but also provide more choices for users who demand high-quality conversion results, enhancing the usefulness of the customer’s app. 

         - Provide a wide range of services: Through the OCR module, the service range of the app can be expanded, meeting the needs of more users and further enhancing the user experience.



Processes

 

Users only need to place the OCR module on their own server and download the OCR module when needed, then use our new interface to use the OCR. When designing the application, you can refer to the following procedure to integrate the OCR module plugin into your PDF to Office application. Our ComPDFKit team can be contacted to plan how to incorporate the OCR module plugin in a unique, complex application.

 

OCR Processes of ComPDFKit Document AI

 

Note: Do not change the file name of the OCR module and model.



OCR Model Loading

 

Furthermore, the method to initialize the SDK on the Windows platform has been adjusted. You need to call the CPDFConverter.Init() interface to load the ComPDFKit conversion library before verifying the license through the CPDFConverter.LicenseVerify() interface. If not done in this order, an error code stating "Library not initialized" will be returned.

 

Windows: The code example to initialize the ComPDFKit conversion library and load the OCR model is as follows. 

string LicenseKey = "your_license_key";
string LicenseSecret = "your_license_secret";
// Call the original Init interface, load the C++ library and some resource files (You need to invoke the Init interface before validating license)
CPDFConverter.Init("your/resource/path");

// Validate license
CPDFConverter.LicenseVerify(LicenseKey, LicenseSecret);

// Load the OCR dynamic library and set the OCR model path
CPDFConverter.InitOCRLibrary("ocr/library/path");
CPDFConverter.SetOCRModelPath("ocr/model/path");

 

Mac: The code example to load the ComPDFKit OCR model is as follows.

 
NSString *documentPath =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    NSString *tDocPath = [NSString stringWithFormat:@"%@/%@", documentPath, @"DocumentAI.bundle"];
    if([[NSFileManager defaultManager] fileExistsAtPath:tDocPath]) {
        [CPDFConvertKit setOCRModelPath:tDocPath];
    } 

Ready to Get Started?

Download our all-in-one ComPDFKit for free and run it to your project within minutes!