使用 Google 脚本编辑器将 PDF 转换为 Doc
Convert PDF to Doc with Google Script Editor
我希望使用 Google 脚本编辑器将 PDF 转换为 google Drive 中的 Doc。但是不断收到错误消息 "Converting from application/pdf to application/doc is not supported"。在脚本中可以进行这种转换吗?我的尝试如下,很高兴听到任何建议。
function convertdPDF2doc() {
var pdffile = DriveApp.getFileById();
var pdfblob = pdffile.getAs('application/doc');
pdfblob.setName(doc.getName() + ".doc");
DriveApp.createFile(docblob);
}
function pdfToDoc() {
var fileBlob = DriveApp.getFileById('0B3m2D6239t6aWHo5TVpyYzhxV1U').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);
}
将驱动器 API 添加到 google 应用程序脚本项目
https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services
下载后可以在 google 驱动器上看到 pdf 文件 ID http://i.imgur.com/3pYvwjx.png
我希望使用 Google 脚本编辑器将 PDF 转换为 google Drive 中的 Doc。但是不断收到错误消息 "Converting from application/pdf to application/doc is not supported"。在脚本中可以进行这种转换吗?我的尝试如下,很高兴听到任何建议。
function convertdPDF2doc() {
var pdffile = DriveApp.getFileById();
var pdfblob = pdffile.getAs('application/doc');
pdfblob.setName(doc.getName() + ".doc");
DriveApp.createFile(docblob);
}
function pdfToDoc() {
var fileBlob = DriveApp.getFileById('0B3m2D6239t6aWHo5TVpyYzhxV1U').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);
}
将驱动器 API 添加到 google 应用程序脚本项目 https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services
下载后可以在 google 驱动器上看到 pdf 文件 ID http://i.imgur.com/3pYvwjx.png