Merge Multiple PDF's into one PDF

后端 未结 6 734
一整个雨季
一整个雨季 2020-11-30 10:36

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

6条回答
  •  臣服心动
    2020-11-30 11:32

    Here's the code to concatenate the blobs, but like Serge mentioned, it doesn't actually work, and the PDF comes out corrupt.

    function MergeFiles(){
    var folder = DocsList.getFolderById('myFolderID'); 
    var files = folder.getFiles(); 
    
    var blobs = "";    
    for( var i in files )   
    blobs=blobs+(files[i].getBlob().getBytes());
    Logger.log(blobs);
    var myPDF = Utilities.newBlob(blobs, "application/pdf", "newPDF.pdf");
    folder.createFile(myPDF);
    
        }
    

提交回复
热议问题