Created
June 26, 2019 12:54
-
-
Save qaisjp/793efddbaf2429c3cc64a092be8b6d0e to your computer and use it in GitHub Desktop.
Set "onOpen" as the default function. Provide a script property "pdf" with value = the file ID of your pdf document
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 onOpen() { | |
var ss = DocumentApp.getUi(); | |
ss.createMenu("qais.jp/cv") | |
.addItem("Deploy this", "actionDeploy") | |
.addToUi(); | |
}; | |
function getPDFFile() { | |
const id = PropertiesService.getScriptProperties().getProperty("pdf"); | |
return DriveApp.getFileById(id); | |
} | |
function actionDeploy() { | |
const f = getPDFFile() | |
const docblob = DocumentApp.getActiveDocument().getAs('application/pdf'); | |
Drive.Files.update( | |
{ | |
title: f.getName(), | |
mimeType: f.getMimeType() | |
}, | |
f.getId(), | |
docblob, | |
{supportsTeamDrives: true} | |
); | |
DocumentApp.getUi().alert("Deployed!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment