-
-
Save sytabaresa/5470600 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 spreadsheetToPDF(key) { | |
var oauthConfig = UrlFetchApp.addOAuthService("spreadsheets"); | |
var scope = "https://spreadsheets.google.com/feeds" | |
oauthConfig.setConsumerKey("anonymous"); | |
oauthConfig.setConsumerSecret("anonymous"); | |
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope); | |
oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken"); | |
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); | |
var requestData = { | |
"oAuthServiceName": "spreadsheets", | |
"oAuthUseToken": "always", | |
}; | |
var name = DocsList.getFileById(key).getName()+".pdf"; | |
var pdf = UrlFetchApp.fetch("https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key="+key+"&exportFormat=pdf&gid=1&gridlines=0&printtitle=0&size=7&fzr=true&portrait=1&fitw=1", requestData).getBlob().setName(name); | |
return pdf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment