Forked from phillypb/Convert Google Doc to PDF in a given folder.gs
Created
April 27, 2022 13:41
-
-
Save cwlind/fd25617cf4624705f9b34697e205a610 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