I am having some issues with my code. I am trying to loop through a Drive folder that contains many PDFs and then merge these into one file. When I use my code it just creat
I'm also having the same problem, and I'm temporarily using a RestFul API to merge the PDFs: https://www.convertapi.com/pdf-to-merge
function merge() {
var folder = DriveApp.getFolderById(''); // folder with files pdf
var files = folder.getFiles(); // get all files pdf
var formData = {};
var index = 0;
while(files.hasNext()) {
var file = files.next();
formData['Files[' + index + ']'] = file.getBlob();
index++;
}
var options = {
'method' : 'post',
'payload' : formData,
'muteHttpExceptions': true
};
var response = UrlFetchApp.fetch('https://v2.convertapi.com/pdf/to/merge?Secret=', options);
if(response.getResponseCode() == 200) {
var contentText = JSON.parse(response.getContentText());
var blob = Utilities.base64Decode(contentText.Files[0].FileData);
folder.createFile(Utilities.newBlob(blob, 'application/pdf', 'merge.pdf'));
}
}