0

I need to convert google doc files into jpeg files and then save them in my google drive.

i have found code that fixes a similar problem 1)Is there a Google Appscript command that can convert a .gDraw to a .jpg? 2)Can a trigger be set to perform this conversion on .gdraw file edit? here but I am not sure how use a google doc file instead of a gDraw file

function gDrawTO_jpeg(){
  var gDrawFile = Drive.Files.get('your_draw_file_ID_here'); 
  var url = gDrawFile.exportLinks['image/jpeg'];
  var token = ScriptApp.getOAuthToken();
  var response = UrlFetchApp.fetch(url, {
    headers: {
      'Authorization': 'Bearer ' +  token
    }
  });
  var jpeg = response.getBlob();
  DriveApp.createFile(jpeg);
}
Mark.B
  • 31
  • 1
  • 5

1 Answers1

1

You can do this by creating a temporary Sheets file, recreating the document content on that spreadsheet file then exporting the sheet to an image.

Here is how I did this for Sheets (not Docs). The process should be fairly similar.

You could also submit a Feature Idea for this.

ZektorH
  • 2,680
  • 1
  • 7
  • 20