I wrote this script to create a gdocs filled with data from a google spreadsheet:
function autoFillGoogleDocFromForm(e) {
var timestamp = e.values[0];
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();
var theDate = curr_year + "0" + curr_month + curr_date;
var contractualpartner = e.values[2];
var address = e.values[3];
var companyno = e.values[4];
var signee = e.values[5];
var title = e.values[6];
var templateFile = DriveApp.getFileById("1eVqeRAyBPM4VDGlByDj3LAiDpzky2-eDO_pZz0IP_4E");
var templateResponseFolder = DriveApp.getFolderById("1OVUma_-u6RYaw8qVRbxH8yF58x0MCwd8");
var copy = templateFile.makeCopy(theDate + '_' + "YYY" + '_' + "XXX" + '&' + contractualpartner, templateResponseFolder);
var doc = DocumentApp.openById(copy.getId())
var body = doc.getBody();
body.replaceText("{{Partner}}", contractualpartner);
body.replaceText("{{Address}}", address);
body.replaceText("{{Company Number}}", companyno);
body.replaceText("{{Signee}}", signee);
body.replaceText("{{Title}}", title);
doc.saveAndClose();
}
This script works perfectly. Now I would like to convert the created gdocs into a pdf document. I have spent some hours searching for a solution but didn't find one. I found a solutions where all documents in the folder would be converted from gdocs to pdf but I would like to only convert the new entry in the spreadsheet. Every gdoc should have only one pdf document.