Get text from PDF in Google

ぐ巨炮叔叔 提交于 2020-01-24 00:25:10

问题


I have a PDF document that is saved in Google Drive. I can use the Google Drive Web UI search to find text in the document.

How can I programmatically extract a portion of the text in the document using Google Apps Script?


回答1:


See pdfToText() in this gist.

To invoke the OCR built in to Google Drive on a PDF file, e.g. myPDF.pdf, here is what you do:

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...
}


来源:https://stackoverflow.com/questions/38166664/get-text-from-pdf-in-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!