Erickuacho
Erickuacho

Reputation: 13

Store PDF to Google Drive

Does anybody know how to do a Script tha create a PDF from a Google Doc and store it into Google Drive?, this was my function

  var Folder = DocsList.getFolder(FOLDER);


  var doc = DocsList.getFileById(DOC_ID);
 var docName = doc.getName();
  var pdf = doc.getAs('application/pdf').getBytes();

 //This suppose to be the accion, but such function cant be found 
 pdf.addToFolder(Folder);

Upvotes: 1

Views: 250

Answers (1)

Phil Bozak
Phil Bozak

Reputation: 2822

Try

var pdf = doc.getAs('application/pdf');
Folder.createFile(pdf);

To keep things simple, you want to keep your file contents as a Blob. (i.e. don't call getBytes(). Then create a file using the Blob. Folder.createFile(...) is the function that you were looking for.

Upvotes: 2

Related Questions