7 Replies Latest reply on Feb 19, 2013 11:41 PM by -hans-

    Auto-import images based on variable

    MikeBrog Level 1

      I would like to automate the import of several images onto a single page.

       

      The person working on the page should receive a prompt asking for a publication name and a date.

       

      The publication would be used to tell the script in which network folder to find the images.

       

      The date would be used to construct the file name based on which picture frame the script is currently working on.

       

      The single-page InDesign template they are working on would have several picture frames.  The frames will "never" change.

       

      Although I'm sure there's something out there like this, I've be unable to find anything.

       

      Anyone know of anyting or willing to share any code to get me started?

       

      Thanks.

       

      ID 5.5, Windows 7, Java Script

        • 1. Re: Auto-import images based on variable
          -hans- Level 4

          Hi,

           

          you'll find parts but not your special workflow. Without any experience in scripting ...

           

          If you don't want to spent time yourself -> think of investing a bit of money to anyone who'll spent his'

          • 2. Re: Auto-import images based on variable
            MikeBrog Level 1

            I do have scripting and programming experience, but JavaScript is not my forte...

            • 3. Re: Auto-import images based on variable
              -hans- Level 4

              Hi,

               

              what should be the sources for the publication names and a dates to be provided?

              • 4. Re: Auto-import images based on variable
                Colin Flashman Adobe Community Professional

                has the OP looked into Fuga Tech? http://fuga-tech.com/

                 

                I think it might do what the OP is after.

                 

                In the interest of full disclosure, I am NOT an employee of fuga tech, nor receive any payment announcing this link.

                 

                Colly

                • 5. Re: Auto-import images based on variable
                  -hans- Level 4

                  Hi,

                   

                  if you still want to do it yourself. Let's do the first step.

                  Here's a example for the userdialog. Release dates will livechange depending on selected publication.

                   

                  #target Indesign
                  
                  
                  //e.g set some sample publications and release dates
                  var publications = new Array ();
                  
                  var publication01 = new Object();
                  publication01 ["publication"] = "newspaper" ;
                  publication01 ["releaseDates"] = ["ndate01", "ndate02", "ndate03"] ;
                  publications.push(publication01);
                  
                  var publication02 = new Object();
                  publication02 ["publication"] = "magazine" ;
                  publication02 ["releaseDates"] = ["mdate01", "mdate02", "mdate03"] ;
                  publications.push(publication02);
                  
                  //alert the response
                  alert('Chosen Product & release Date: ' + someDialog().join(', '));
                  
                  
                  
                  //userdialog
                  function someDialog()
                  {
                  var w = new Window ("dialog", "My Input");
                   w.alignChildren = "left";
                  var pnlpublication  = w.add('panel', undefined, 'Please choose a publication:'); 
                  pnlpublication.orientation = "row";
                  var myPublication = pnlpublication.add ("dropdownlist", [0, 0, 250, 10], [publications[0].publication,  publications[1].publication]);
                  myPublication.selection = 0;
                  
                  var pnlDate  = w.add('panel', undefined, 'Please choose a release Date:'); 
                  pnlDate.orientation = "row";
                  var myDate = pnlDate.add ("dropdownlist", [0, 0, 250, 10],publications[0].releaseDates);
                  myDate.selection = 0;
                  
                  var myButtonGroup = w.add ("group");
                  myButtonGroup.orientation = "row";
                  myButtonGroup.add ("button", undefined, "OK"); 
                  myButtonGroup.add ("button", undefined, "Cancel");
                  
                  myPublication.onChange = function() {
                      myDate.removeAll();    
                      var getSel = myPublication.selection.text;
                      
                      switch(getSel){
                  case publications[1].publication : setListItems (publications[1].releaseDates); break;
                  default : setListItems (publications[0].releaseDates); break;
                          }
                      
                     function setListItems (stringArray){
                          for(var myItem = 0; myItem < stringArray.length; myItem++){
                      myDate.add('item', stringArray[myItem])
                  }    
                      }
                  myDate.selection = 0;
                  
                  }
                  
                  if (w.show () == 1){
                      
                      return [myPublication.selection.text, myDate.selection.text];
                      w.close()
                  }else{
                      w.close();
                  exit ();
                  }
                  }
                  
                  1 person found this helpful
                  • 6. Re: Auto-import images based on variable
                    MikeBrog Level 1

                    I was able to change the date field pop-down to a edittext field and grab the needed info with a few very small modifications.

                     

                    I was also able to put it together with another script which will place an image onto the page based on a string in a text box.

                     

                    Since the pages always have exactly the same boxes on them, I'm thinking it might make more sense to grab the info and do a search and replace and then have the other script pull in the images.

                     

                    For instance, it would search for {YYMMDD} and replace it with the info the user input into the date edittext field.

                     

                    Thanks for the start!

                    • 7. Re: Auto-import images based on variable
                      -hans- Level 4

                       

                       

                      Your rules for placing the images are not as detailed explained. So I would, but can't give good advice here.

                      Keep in mind that page items can be labelled (Both: scriptlabel or GUI-label) and named.

                       

                      Happy scripting!

                       

                      Hans-Gerd Claßen