我希望从电子表格生成受保护的 PDF,特别是设置安全选项以防止复制。
到目前为止,我生成了这样的 PDF:
function convert(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Sheet1");
var id = ss.getId();
var url = 'https://docs.google.com/feeds/';
var doc = UrlFetchApp.fetch(url+'download/spreadsheets/Export?key='+id+'&exportFormat=pdf',googleOAuth_('docs',url)).getBlob();//pdf
DocsList.createFile(doc).rename('pdfexport.pdf');
var pdffileID = DocsList.createFile(doc).getId()
var file = DocsList.getFileById(pdffileID);
Logger.log("file type : "+file.getFileType());
}
function googleOAuth_(name,scope){
var oAuthConfig = UrlFetchApp.addOAuthService(name);
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey('anonymous');
oAuthConfig.setConsumerSecret('anonymous');
return {oAuthServiceName:name, oAuthUseToken:"always"};
}
有没有办法从 Google Drive 生成安全的 PDF 文件,或者它不受支持?