【发布时间】:2016-07-03 04:12:30
【问题描述】:
我有一个保存在 Google 云端硬盘中的 PDF 文档。我可以使用 Google Drive Web UI 搜索来查找文档中的文本。
如何使用 Google Apps 脚本以编程方式提取文档中的部分文本?
【问题讨论】:
标签: pdf google-apps-script google-drive-api drive
我有一个保存在 Google 云端硬盘中的 PDF 文档。我可以使用 Google Drive Web UI 搜索来查找文档中的文本。
如何使用 Google Apps 脚本以编程方式提取文档中的部分文本?
【问题讨论】:
标签: pdf google-apps-script google-drive-api drive
在this gist 中查看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...
}
【讨论】: