Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwlind/fd25617cf4624705f9b34697e205a610 to your computer and use it in GitHub Desktop.
Save cwlind/fd25617cf4624705f9b34697e205a610 to your computer and use it in GitHub Desktop.
function docToPDF() {
// ID of Google Doc
var docID = 'ENTER ID HERE';
// ID of destination folder
var folderID = 'ENTER ID HERE';
// get Google Drive folder
var folder = DriveApp.getFolderById(folderID);
// get Google Doc file
var file = DriveApp.getFileById(docID);
// get file content as PDF blob
var pdfBlob = file.getAs('application/pdf');
// create new PDF file in Google Drive folder
folder.createFile(pdfBlob);
// delete original Google Doc file
file.setTrashed(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment