我正在使用以下代码基于Google工作表生成pdf,然后将其作为电子邮件附件发送。
function emailReport() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName("Students"));
var subject = spreadsheet.getRange("U1:U1").getValues();
var emailTo = spreadsheet.getRange("V1:V1").getValues();
var message = spreadsheet.getRange("W1:W1").getValues();
var fileName = spreadsheet.getRange("X1:X1").getValues();
var ui = SpreadsheetApp.getUi();
var response = ui.alert("Do you want to send the report to this email?",emailTo, Browser.Buttons.YES_NO);
if (response == ui.Button.YES) {
readyForExport();
var pdf = DriveApp.getFileById(spreadsheet.getId()).getAs('application/pdf').getBytes();
var attach = {fileName:fileName[0][0],content:pdf, mimeType:'application/pdf'};
MailApp.sendEmail(emailTo, subject, message, {attachments:[attach]});
ui.alert("The report was successfully sent to "+emailTo+".");
} else {
ui.alert("The report was not sent.");
}
};
问题是我生成的pdf的页面方向是纵向。我希望有一个以横向模式生成的pdf文件,并且我还想将页面大小设置为A4。
有人可以帮忙吗?
预先表示感谢。