Skip to content

Instantly share code, notes, and snippets.

@qaisjp
Created June 26, 2019 12:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qaisjp/793efddbaf2429c3cc64a092be8b6d0e to your computer and use it in GitHub Desktop.
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
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