Created
October 31, 2016 14:46
-
-
Save mannharleen/f044447f456d772d3b2179302f1a3c49 to your computer and use it in GitHub Desktop.
Use RESTfull webservice from ocrwebservice.com to get a document scanned and converted into text
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
public class ocrv1 { | |
//read file contents, sent to http://www.ocrwebservice.com/api/restguide and get ocr response | |
public static void func1() { | |
StaticResource sr = [SELECT Id, name, Body FROM StaticResource where name = 'Simple_Survey_Intro' LIMIT 1]; | |
String b64String = EncodingUtil.base64Encode(sr.Body); | |
String hexString = EncodingUtil.convertToHex(sr.Body); | |
system.debug('\n b64= '+b64String +'\n hex= '+hexString); | |
Http http = new Http(); | |
HttpRequest request = new HttpRequest(); | |
request.setMethod('POST'); | |
request.setEndpoint('http://www.ocrwebservice.com/restservices/processDocument?language=english&pagerange=1-5&gettext=true&outputformat=doc'); | |
request.setHeader('Authorization', 'Basic TUFOTkhBUkxFRU46OUVFRkMwRjEtREQ1RC00QUYxLUFGMzMtRDQ4MzhGQUU4MERE'); | |
request.setBody(b64String); | |
HttpResponse response = http.send(request); | |
system.debug('\n Response = ' + response.getBody()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment