Rename PDF files, while saving Google sheet as pdf TO DESKTOP

Viewed 25

Can I have a dynamic name for my pdf file. For example values in cell C3 of active sheet with '.pdf' extension.

Any modifications to the script?

Using this code to Export PDF

function downloadSheetAsPDF() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheetId = ss.getActiveSheet().getSheetId();
  var url = "https://docs.google.com/a/mydomain.org/spreadsheets/d/" + ss.getId() + "/export?exportFormat=pdf&gid=" + sheetId + "&access_token=" + ScriptApp.getOAuthToken();
  var str = '<input type="button" value="Download" onClick="location.href=\'' + url + '\'" >';
  var html = HtmlService.createHtmlOutput(str);
  SpreadsheetApp.getUi().showModalDialog(html, "sample");
}
0 Answers
Related