Upload PDF with OCR with google apps script (and p

2020-04-20 14:14发布

I'm using Google Apps script to upload a pdf from the web, but I'd like to upload it while automatically performing OCR. So far, I can upload it, but I don't know how to perform OCR on it.

  var link = "http://ilwu13.com/dispatches/" ;
  var date_str = "011813" ; //My code creates this based on today's date
  var link_end = "_DF.pdf" ;

  link = link + date_str + linkend ;


  var urlfetch = UrlFetchApp.fetch(link) ;
  var fileBlob = urlfetch.getBlob();
  var new_gdoc = DocsList.createFile(fileBlob) ;

I understand this question was already answered in this post, https://developers.google.com/google-apps/documents-list/#uploading_documents_using_optical_character_recognition_ocr, but the "Google Documents List API has been officially deprecated" after it was posted.

The deprecated DocsList API will work until 2015, but I'd like a more stable solution.

1条回答
Ridiculous、
2楼-- · 2020-04-20 14:51

This is possible with the Drive API. See the drive.files.insert method with special attention to the ocr and ocrLanguage parameters.

查看更多
登录 后发表回答