Convert PDF to Doc with Google Script Editor

后端 未结 1 1052
执念已碎
执念已碎 2021-01-13 22:21

I\'m looking to convert PDF to google Doc in Drive using Google Script Editor. However keep getting error message \"Converting from application/pdf to application/doc is not

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-13 23:06

    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);  
    }
    

    Add Drive API to google apps script project https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services

    You can see you pdf file id on google drive when you download it http://i.imgur.com/3pYvwjx.png

    0 讨论(0)
提交回复
热议问题