Created
October 25, 2021 10:52
-
-
Save phillypb/0b61c265fe12b19a649e9b8a06dda889 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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