简体   繁体   English

在 Google Script 中将 PDF 转换为文本时出错

[英]Error converting PDF to Text in Google Script

I was using this code for some time in Google Script and it stopped working several weeks ago.我在 Google Script 中使用了这段代码一段时间,但几周前它就停止工作了。 Trying to get the code back up but can't seem to figure it out.试图恢复代码,但似乎无法弄清楚。

The error message I get is :我得到的错误信息是:

Exception: Unexpected error while getting the method or property insert on object Apiary.drive.files.异常:在对象 Apiary.drive.files 上获取方法或属性插入时出现意外错误。 (line 125, file "Code") (第 125 行,文件“代码”)

Line 125 is the line:第 125 行是:

var gdocFile = Drive.Files.insert(resource, pdfFile, insertOpts).id; var gdocFile = Drive.Files.insert(resource, pdfFile, insertOpts).id;

 // Save PDF as GDOC resource.title = pdfName.replace(/.pdf$/, ''); var insertOpts = { ocr: true, ocrLanguage: options.ocrLanguage || 'en', uploadType: 'multipart' }; var gdocFile = Drive.Files.insert(resource, pdfFile, insertOpts).id; //Get text from GDOC var gdocDoc = DocumentApp.openById(gdocFile); var text = gdocDoc.getBody().getText();

Problem resolved by using the information from the following post: Google App Script : how to convert PDF to GDOC in order to get OCR?使用以下帖子中的信息解决了问题: Google App Script : how to convert PDF to GDOC to get OCR?

Seems that Drive.Files.insert is no longer supported.似乎不再支持 Drive.Files.insert。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM