8 Replies Latest reply on Sep 25, 2011 4:47 AM by beh_gras_beh

    Export pages with Script Label

    beh_gras_beh Level 1

      Dear People,

       

       

      With

      f = File (myFolder + "/" + p[i].textFrames.item (labelname).contents + ".pdf") 
      

      I can export each page to a pdf with a specific name.

       

       

      The problem only is I always have to put the label to each page.

      Is there a way it only exports when he finds a begin and end in one inDesign file.

       

       

      Like this:

      (This is one inDesign file)

       

       

      Start     

      p[i].textFrames.item (pdf_part_1)
      

      Page 1

      Page 2 and 3 (spread)

      Page 4 and 5 (spread)

      Page 6

      End         

      p[i].textFrames.item (pdf_part_1)
      

      Start

      p[i].textFrames.item (pdf_part_2)
      

      Page 7

      Page 8 and 9 (spread)

      Page 10

      End

      p[i].textFrames.item (pdf_part_2)
      

       

      So there has to be 2 PDF's named pdf_part_1.PDF and pdf_part_2.PDF

      pdf_part_1.PDF (6 pages)

      pdf_part_2.PDF (4 pages)

       

       

      Is this even possible with script label?

       

       

      For the record I put the code below.

      (It's not that beautiful, but hey, it works.)

       

      var myDoc = app.documents[0];
      app.scriptPreferences.version = "6.0"
      
      
      if(app.documents.length != 0){   
                var myFolder = Folder.selectDialog ("Choose a Folder");   
                if(myFolder != null){   
                          myExportPages(myFolder);   
                }   
      }   
      else{   
                alert("Please open a document and try again.");   
      }   
      function myExportPages(myFolder){   
                var myDocument = app.activeDocument;   
                var myDocumentName = myDocument.name;   
                var myPDFPresets = app.pdfExportPresets; 
                var myPDFPresetNames = new Array; 
                for (i = 0; i < myPDFPresets.length; i++) 
                          myPDFPresetNames.push(myPDFPresets[i].name);  
      
                var myDialog = app.dialogs.add();   
                with(myDialog.dialogColumns.add()){  
      
      
                          with(dialogRows.add()){  
                                    with(dialogColumns.add()){  
                                              staticTexts.add({staticLabel:"PDF preset: ", minWidth:130});  
                                    }  
                                    with(dialogColumns.add()){  
                                              var myPDFPresetsDropdown = dropdowns.add({stringList:myPDFPresetNames,  selectedIndex:0});  
                                    }  
                          }  
                } 
                var myResult = myDialog.show({name:"ExportPages"});   
                if(myResult == true){   
                          var myPDFPresetName = myPDFPresetNames[myPDFPresetsDropdown.selectedIndex]; 
                          //Remove the dialog box from memory.   
                          myDialog.destroy();   
      
      
      doc = app.activeDocument; 
      doc.sections.everyItem().includeSectionPrefix = false; 
      p = app.activeDocument.pages.everyItem().getElements();
      for (i = 0; i < p.length; i++)
      {   
      
      
      
      
                          var pagelist=prompt("Wich pages?\nformat: 1,2,3,4");
      
                          for (i = 0; i < myDoc.pages.length; i++) {
                             if (pagelist.match("\\b"+myDocument.pages[i].name+"\\b")){
              myFile = File (myFolder + "/" +myDocument.pages[i].textFrames.item ('labelname').contents + ".pdf");
              app.pdfExportPreferences.pageRange = myDocument.pages[i].name;
              myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFPresets.item(myPDFPresetName));
                          }   
                }  
      

       

      As always thanks for the reply's and greetings from Holland!