我有基本的脚本做工精细,但它正是我想要它做的。 Google Sheet会将其转换为PDF并将其通过电子邮件发送给PDF。PDF利润率 - 谷歌脚本
我的问题是如何调整对PDF的利润率,我需要设置PDF以适合页面。我不能调整纸张大小,因为它会抛出间距。
/* Email Google Spreadsheet as PDF */
function PDF() {
// Send the PDF of the spreadsheet to this email address
var email = "gmail.com";
// Get the currently active spreadsheet URL (link)
var ss = SpreadsheetApp.openByUrl(
'https://docs.google.com');
// Subject of email message
var subject = "PAR - " + ss.getRange("A6:A6").getValue() +" - "+ ss.getRange("A5:A5").getValue();
// Email Body can be HTML too
var body = "Name - " + ss.getRange("A6:A6").getValue() +" - "+ ss.getRange("A5:A5").getValue();
var blob = DriveApp.getFileById(ss.getId()).getAs("application/pdf");
blob.setName("Name - " + ss.getRange("A6:A6").getValue() +" - "+ ss.getRange("A5:A5").getValue() + ".pdf");
// If allowed to send emails, send the email with the PDF attachment
if (MailApp.getRemainingDailyQuota() > 0)
GmailApp.sendEmail(email, subject, body, {
htmlBody: body,
attachments:[blob]
});
}
我见过这样的脚本,但不知道如何让它在我的脚本上工作。
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf/csv/xls/xlsx
+ '&size=letter' // paper size legal/letter/A4
+ '&portrait=false' // orientation, false for landscape
+ '&fitw=true&source=labnol' // fit to page width, false for actual size
+ '&sheetnames=false&printtitle=false' // hide optional headers and footers
+ '&pagenumbers=false&gridlines=false' // hide page numbers and gridlines
+ '&fzr=false' // do not repeat row headers (frozen rows) on each page
+ '&gid='; // the sheet's Id
我不认为Google Apps脚本支持从提供的默认设置尚未预留比例为。您可以查看[云端硬盘服务](https://developers.google.com/apps-script/reference/drive/),但似乎没有提及此功能。 – noogui