问题描述
我正在寻找一种使用 Google Apps 脚本下载 PDF 文件并将文件转换为 Google 表格的方法。
这是因为网站只提供PDF格式的数据,无法使用Import功能获取实时更新的数据
解决方法
这取决于您下载 pdf 文件的方式。
以下是如何将 Google Drive 中的 PDF 文件转换为 Googe 文档的简单示例:
function pdfToDoc() {
var fileBlob = DriveApp.getFilesByName('test.pdf').next().getBlob();
var resource = {
title: fileBlob.getName(),mimeType: fileBlob.getContentType()
};
var options = {
ocr: true
};
var docFile = Drive.Files.insert(resource,fileBlob,options);
Logger.log(docFile.alternateLink);
}
要使其工作,您需要启用 Drive API:
基于答案:https://webapps.stackexchange.com/a/136948
据我所知,只有 DOC 作为输出。可能您可以从 DOC 中提取数据并使用脚本将其放入电子表格中。但这取决于您的数据的外观。