Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle docs OCR implementation iphone
    text
    copied!<p>I am trying to integrate google docs OCR feature in my iPhone app. Below is what google docs documentation says.</p> <p>To perform OCR on a .pdf, .jpg, .png, or .gif file, include the ocr=true parameter when uploading a file:</p> <pre><code>POST /feeds/default/private/full?ocr=true GData-Version: 3.0 Authorization: &lt;your authorization header here&gt; Content-Length: 1984 Content-Type: image/png Slug: OCRd Doc ... png contents here ... </code></pre> <p>Now, I am using the following code to make that HTTP post request.</p> <pre><code> responseData = [[NSMutableData data] retain]; NSURL *url = [NSURL URLWithString:@"http://docs.google.com/feeds/default/private/full?ocr=true"]; UIImage *img = [UIImage imageNamed:@"Submit-top.png"]; NSData *data = UIImagePNGRepresentation(img); int a = [data length]; NSString *imgLength = [NSString stringWithFormat:@"%d" ,a]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:url]; [request setHTTPBody:data]; [request setHTTPMethod:@"POST"]; [request addValue:@"3.0" forHTTPHeaderField:@"GData-Version:"]; [request addValue:auth.accessToken forHTTPHeaderField:@"Authorization:"]; [request addValue:imgLength forHTTPHeaderField:@"Content-Length:"]; [request addValue:@"image/png" forHTTPHeaderField:@"Content-Type:"]; [request addValue:@"OCRd Doc" forHTTPHeaderField:@"Slug:"]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *str = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSLog(@"%@", str); </code></pre> <p>but I get a response with status code 400.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload