Community

processFields method java example

Hi, I love the new processTextField function you guys have added. It is exactaly what I need!! I am however struggling to get the call working. Using Android I have the following code that submits one text field

public Task  processTextField( String filePath, ProcessingSettings settings) throws Exception
{
    URL url = new URL("http://cloud.ocrsdk.com/processTextField?" + settings.AsUrlParams());
    byte[] fileContents = readDataFromFile( filePath );
    HttpURLConnection connection = openPostConnection(url);
    connection.setRequestProperty("Content-Length", Integer.toString(fileContents.length));
    connection.getOutputStream().write( fileContents );
    BufferedReader reader = new BufferedReader( new InputStreamReader( connection.getInputStream()));
    return new Task(reader);
}

settings.AsUrlParams() return the string "language=English&textType=handprinted&oneTextLine=true&oneWordPerTextLine=true&markingType=underlinedText", and filePath is the path to my JPEG file.

Would it be possible to get a code example of how to post the XML file you speak of here (http://ocrsdk.com/documentation/specifications/xml-scheme-field-settings) in Java? So for example you have an image and there are 2 or 3 text fields you want to submit at once.

Thanks Al

Was this article helpful?

0 out of 0 found this helpful

Comments

1 comment

Please sign in to leave a comment.