[英]How to send email from google sheet with the sheet as a PDF attachment
[英]How to download a PDF file from Google Sheet with specific margins and page breaks?
它允許您通過將它們添加到 url 來指定不同的打印選項,其中包括邊距和網格線。
樣本:
function myFunction() {
var token = ScriptApp.getOAuthToken();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var id = ss.getId();
var url = "https://docs.google.com/spreadsheets/d/"+id+"/export?";
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf / csv / xls / xlsx
+ '&size=letter' // paper size legal / letter / A4
+ '&portrait=true' // orientation, false for landscape
+'&top_margin=0.50'
+'&bottom_margin=0.50'
+'&left_margin=0.50'
+'&right_margin=0.50'
+ '&gridlines=false'
// other parameters if you need
/*
+ '&fitw=true&source=labnol' // fit to page width, false for actual size
+ '&sheetnames=false&printtitle=false' // hide optional headers and footers
+ '&pagenumbers=false' // hide page numbers
+ '&fzr=false' // do not repeat row headers (frozen rows) on each page
+ '&gid='; // the sheet's Id
*/
var response = UrlFetchApp.fetch(url + url_ext,
{
headers: {
'Authorization': 'Bearer ' + token
},
muteHttpExceptions:true
});
DriveApp.createFile(response.getBlob().setName("myPdf"));
}
不幸的是,我不知道設置分頁符的方法,但人們正在使用變通方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.