1 Reply Latest reply on Sep 23, 2015 12:15 AM by Vamitul

    Change the save location

    evan71922978

      Hi !

       

      Actually, my script save the exported pdf file on the Desktop, but I want to change it and put it in my serveur, here : \\Exemple-srv\exp\01_EXP_SCRIPT

       

      Can you help me ?

       

      My code :

       

      app.activeDocument.dataMergeProperties.mergeRecords(); 
      
           var myDocument = app.activeDocument;
      main();  
           
      function main(){
      exportPDF();  
      
      }                              
      function exportPDF(){          
           var myPageName, myFilePath, myFile;           
           var myPDFExportPreset = app.pdfExportPresets.item("[Qualité supérieure]");  
           
      for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){ 
      myPageName = myDocument.pages.item(myCounter).name;   
      app.pdfExportPreferences.pageRange = myPageName;       
           var myRegExp = /:/gi;
               
      myPageName = myPageName.replace(myRegExp, "_");    
      myFilePath = Folder.desktop + "/" + extractPAFname(myCounter) + ".pdf";
       myFile = new File(myFilePath);    
      myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset);  
      
      }  
            
      }  
         
      function extractPAFname(AllPages){  
      
           var myStyle = myDocument.paragraphStyles.itemByName('nom_fichier');         
      if (myStyle.isValid){  
           app.findGrepPreferences = app.changeGrepPreferences = null;   
           app.findGrepPreferences.appliedParagraphStyle = myStyle;  
           var mySearch = myDocument.findGrep();  
      if (mySearch.length >0){       
      return mySearch[AllPages].contents  
           
      }else{  
      alert('Erreur - Pas de texte');  
      exit();  
                
           }    
          
      }else{  
      alert('Erreur - Pas de style');  
      exit();
                   
           }               
      }