Attaching the snippet of my code. I have an input spreadsheet where the end-user enters in an email address. Then, the code will open my desired spreadsheet, converts it to a PDF and sends to the email. I have the code working perfectly with the exception that the margins are off on the PDF sent via email. I have a similar script that allows the end-user to just download the PDF and the margins work when performing that function. Both options are generated from the same sheet so kind of lost as to why the margins are off when sending via email.
var printRange = '&c1=0'+'&r1=0'+'&c2=41'+'&r2=5'; // B2:APn var url= ss.getUrl().replace(/edit$/, '') +"format=pdf&"+"fmcmd=12&"+"size=0&"+"fzr=true&"+"gid="+322778635+"&"+"sheetnames=false&"+"pagenum=UNDEFINED&"+"gridlines=true&"+"portrait=true&"+"scale=2&"+"fitw=false&"+"horizontal_alignment=CENTER&"+"top_margin=0.00&"+"bottom_margin=0.00&"+"left_margin=0.00&"+"right_margin=0.00&"+"ir=false&"+"ic=false&"+"r1=0&"+"c1=0&"+"r2=41&"+"c2=5&"+"printtitle=false&" +"attachment=true&"+ printRange; var blob = DriveApp.getFileById(ss.getId()).getAs("application/pdf"); blob.setName(ss.getName() +".pdf"); var templ = HtmlService .createTemplateFromFile('candidate-email'); templ.candidate = candidate; var message = templ.evaluate().getContent(); MailApp.sendEmail({ to: candidate.email, subject: "New Invoice Submitted from Group!", htmlBody: message, attachments: [blob], }); // Send Alert Email. // var message = CustomerName + emailmessage; // Second column // var subject = 'New Invoice Submitted'; // MailApp.sendEmail(emailAddress, subject, message , { // }); SpreadsheetApp.getActive().getSheetByName('InvoiceTemplate1').showSheet(); SpreadsheetApp.getActive().getSheetByName('Template1').hideSheet();}