goa*_*guy 3 pdf drive google-apps-script google-drive-api
我有一个保存在 Google Drive 中的 PDF 文档。我可以使用 Google Drive Web UI 搜索来查找文档中的文本。
如何使用 Google Apps 脚本以编程方式提取文档中的一部分文本?
见pdfToText()
在此要点。
要在 PDF 文件上调用 Google Drive 内置的 OCR,例如myPDF.pdf
,您可以执行以下操作:
function myFunction() {
var pdfFile = DriveApp.getFilesByName("myPDF.pdf").next();
var blob = pdfFile.getBlob();
// Get the text from pdf
var filetext = pdfToText( blob, {keepTextfile: false} );
// Now do whatever you want with filetext...
}
Run Code Online (Sandbox Code Playgroud)