• Purpose

    This article provides a solution for how to fetch multiple pdf documents from Sharepoint 365, zip them and upload the zip to Sharepoint 365.

    Resolution

    PDF filenames are present in input data file.

    1. Run a script on the rearrange to fetch the pdfs from sharepoint 365 via Sharepoint Command and save them in a temporary folder based on the JobInfo docno from data. Docno also used to name the file.

    function GetDocumentsAndZip()

    {

    job.setJobInfo("documentname", CurrentText);

    sharepointcommands['SP GetDocuments'].run(job);

     

    createDirectory("C:\\Lasernet\\8.0\\PDF-Zip\\PDFS\\" + job.getJobInfo("docno"));

    var f = new File("C:\\Lasernet\\8.0\\PDF-Zip\\PDFS\\" + job.getJobInfo("docno") + "\\" + job.getJobInfo("documentname")); 

    f.open(IO_ReadWrite); 

    f.writeBinary( job.getJobInfoBinary("SharePointSelectResult")); 

    f.close();

    job.setJobInfo("zipfilename", job.getJobInfo("docno") + ".zip"); 

    }

    2. Run a script as a modifier on “after analysis” that calls 2 modifiers, first one using 7-zip to zip the pdfs into temp folder, second one using cmd.exe to delete pdf files from temp folder

    function ZipPDFS()

    {

    modifiers['ZIP_PDF'].run(job);

    modifiers['DeletePDF_Files'].run(job); 

    }

    3. Run a File Retriever as a modifier “after analysis” to fetch the zip file.

    4. Run a Sharepoint command as modifier “after analysis” to upload the zip file to Sharepoint 365.

    5. Run a process modifier “after analysis” to delete Zip file from temp folder.

    6. Run a process modifier “after analysis” to delete temp folder.

    7. Create rearrange with hyperlink to zip file

    Additional information

    7-Zip needs to be installed

    Small config with all nescessary modules attached.