[英]Convert PDF with images to Google Doc in Google Apps Script
I'm using Google Apps Script and Google Drive API to convert a PDF file which is stored in my drive to Google Doc.我正在使用 Google Apps Script 和 Google Drive API 将存储在我的驱动器中的 PDF 文件转换为 Google Doc。 The problem is, the PDF is converting to Google Doc but images and table formats are not coming in the newly generated doc, only texts and texts with colors are appearing.
问题是,PDF 正在转换为 Google Doc,但图像和表格格式没有出现在新生成的文档中,只有带有 colors 的文本和文本出现。
My codes are given below:我的代码如下:
function pdfToDoc() {
var fileBlob = DriveApp.getFileById('MY_PDF_ID').getBlob();
var resource = {
title: fileBlob.getName(),
mimeType: fileBlob.getContentType()
};
var options = {
ocr: true,
convert: true
};
var docFile = Drive.Files.insert(resource, fileBlob, options);
Logger.log(docFile.alternateLink);
}
Am I doing something wrong here?我在这里做错了吗? I've been searching for solution in web but no luck.
我一直在 web 中寻找解决方案,但没有运气。 How can I convert a PDF perfectly to a Google Doc?
如何将 PDF 完美地转换为 Google Doc?
At the moment, this is not possible.目前,这是不可能的。 Google Drive uses basic OCR in order to transform the PDF into Docs, but it does not handle images - only text.
Google Drive 使用基本的OCR将 PDF 转换为 Docs,但它不处理图像 - 仅处理文本。 If you are still interested in keeping the images you can:
如果您仍然对保留图像感兴趣,您可以:
{convert:true}
to convert it into a Docs file.{convert:true}
上传转换为 Docs 文件。 You can use URLFetchApp for that (in this case, the conversion would work properly since it's from DOC/DOCX type to Docs type, not from PDF which is structured differenly).
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.