The original code basically converts the Google Doc to PDF based on 2 different templates (2 different Google Doc with 2 different keys);
From the Google Form responses, if a standard part is selected, it will send the user an email with a quotation attached (PDF format). If not, then a different template will be sent out to the user instead:
1st template --> A quotation (standard parts)
2nd template --> Request has been received template (non standard parts)
So what I'm trying to do now is instead of using 2 different documents, I would like to have the templates in 1 document but converting only the specific page. For example, template 1 in page 1 and template 2 in pages 2 - 4.
Below code will only convert the whole document into PDF so I wonder if there is a special method or properties like getpagenumber
to convert the specific page.
var docName = "insertdocnamehere";
var custName = "insertcustomernamehere";
var docTemplate = "insertgoogledockeyhere";
var copyId = DriveApp.getFileById(docTemplate)
.makeCopy(docName+' for '+ custName)
.getId();
// Open the temporary document
var copyDoc = DocumentApp.openById(copyId);
// Get the document’s body section
var copyBody = copyDoc.getActiveSection();
copyDoc.saveAndClose();
var pdf = DriveApp.getFileById(copyId).getAs("application/pdf");