Skip to content

Instantly share code, notes, and snippets.

@rcknr
Forked from anonymous/gist:4169590
Last active February 12, 2021 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcknr/93c8fdd88dc9cf90a4628c847d24fc95 to your computer and use it in GitHub Desktop.
Save rcknr/93c8fdd88dc9cf90a4628c847d24fc95 to your computer and use it in GitHub Desktop.
Get Google Spreadsheet as PDF with customizations
function spreadsheetToPDF(key) {
var spreadsheet = SpreadsheetApp.openById(key);
var response = UrlFetchApp.fetch(spreadsheet.getUrl() + '/export?exportFormat=pdf&gid=1&gridlines=0&printtitle=0&size=7&fzr=true&portrait=1&fitw=1', {
muteHttpExceptions: true,
headers: {
Authorization: 'Bearer ' + ScriptApp.getOAuthToken(),
}
});
return response.getBlob();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment