Hi I've got this script that I use to email a set of sheets as a PDF and it's working properly except for the margins I would need to be able to set the margins at 0.5 for the top 0.25 for the sides and 0.6 for the bottom here's my existing script
function createPDF() {
var mainSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Main');
var sheetNames = mainSheet.getRange('B3:B').getValues().flat().filter(String);
var selectedSheets = sheetNames.filter(function(name, i) {
return mainSheet.getRange(i+3, 1).getValue();
});
var sheetsToHide = [mainSheet];
SpreadsheetApp.getActiveSpreadsheet().getSheets().forEach(function(sheet) {
if (sheet.getName() !== 'Main' && sheet.getName() !== 'Template' && sheet.getName() !== 'Import' && selectedSheets.indexOf(sheet.getName()) === -1) {
sheetsToHide.push(sheet);
}
});
sheetsToHide.forEach(function(sheet) {
sheet.hideSheet();
});
var blob = mainSheet.getParent().getAs('application/pdf');
var file = DriveApp.createFile(blob).setName('PDF Report');
GmailApp.sendEmail(Session.getActiveUser().getEmail(), "PDF Report", "", {attachments:[file]});
file.setTrashed(true);
sheetsToHide.forEach(function(sheet) {
sheet.showSheet();
});
updateCheckboxes();
}
Thanks