I have a Google Spreadsheet attached to a Form. On Form Submit, a script takes information from the submission and applies it into carefully placed textboxes in a Google Slide. There are two separate forms which are used to submit information into two separate slides on the SAME presentation.
After the information is entered, the script runs a function that is supposed to export the edited slide ONLY as a PDF and email it to an address provided on the Google Form.
I had a similar setup on a different program of mine and had someone from an online forum help me write the export PDF / Email code. The code they helped me write was for exporting and emailing an individual Spreadsheet sheet.
Here is the email code that I copied from my Spreadsheet program.
function Email3UpPDF () {
Logger.log("Emailing!");
var Sapp = SpreadsheetApp;
var FS = Sapp.getActiveSpreadsheet().getSheetByName("3UP Submissions");
var ssID = "10Up_PcLxVopXont9Qcu-yk-PrFGWfWPQ3ETsgys4v0Y"
var shID = "g2580bcdba17_0_22"
var Addy1 = FS.getRange("N"+FS.getLastRow()).getValue();
var requestData = {"method": "GET", "headers":{"Authorization":"Bearer "+ScriptApp.getOAuthToken()}};
var url = "https://docs.google.com/presentation/d/"+ ssID + "/export?format=pdf&id="+shID; //This creates the PDF export url
var result = UrlFetchApp.fetch(url , requestData);
var contents = result.getContent();
MailApp.sendEmail(Addy1,"Local Sign Template" ,"Here is your custom sign Template.", {attachments:[{fileName: "LST3UP.pdf", content:contents, mimeType:"application/pdf"}]});
}
My HOPE was that I could simply substitute the Spreadsheet ID with a Presentation ID, and the Sheet ID with a Slide ID. When I tried that I was met with this error:
Exception: Request failed for https://docs.google.com returned code 404. Truncated server response: <meta name="viewport" c... (use muteHttpExceptions option to examine full response)
The error points to line 13: var contents = result.getContent();
I should note that when I put JUST the Presentation ID in both the ssID and the shID variables, the program runs successfully but ends up sending a 2 page PDF with both slides on it. Which makes sense to me. My intention is to only have one slide though.