How to get the angle of a document page photo in Salesforce Apex
Determining the angle of rotation for a document can be quite difficult to achieve in Apex. The best means of accomplishing this is using machine learning to yield a high level of accuracy. You probably don’t have time for that whole process, so I will be showing you how to get this done in double quick time using an API.
First download this and drag the client folder into your project:
https://github.com/Cloudmersive/Cloudmersive.APIClient.Apex.OCR/archive/master.zip
Now we can call our function.
SwagPreprocessingApi api = new SwagPreprocessingApi();SwagClient client = api.getClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');Apikey.setApiKey('YOUR API KEY');Map<String, Object> params = new Map<String, Object>{'imageFile' => Blob.valueOf('Sample text file\nContents')};try {// cross your fingersSwagGetPageAngleResult result = api.preprocessingGetPageAngle(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}
And you are officially done.
