6 Replies Latest reply on Oct 6, 2012 1:05 PM by -hans-

    Can this be done?


      I have a challenge ahead of me that I don't know is even possible to achieve!


      A have a document containing hundreds of spreads that each contain a linked photograph. This linked photograph needs to be used as a guide for bringing in more links to that same spread. Ideally they'd be placed as illustrated below i.e. sequentially in designated placeholders.


      The way that the linked photograph will help is that it's own filename is effectively a list (separated by X_'s) of which files to go and fetch.



      End result (hopefully!) :



      It seems like a very logical process but I'm not sure if it can be done with scripting in InDesign. What do we reckon?

        • 1. Re: Can this be done?
          Manan Joshi Level 4

          This is doable in my opinion, what is holding you up on in implemnting this solution. I would try and propose a solution where in we iterate thruogh every page of a spread and for each page create a graphic frame with dimeensions equal to that of the page. Once that is done we import the image into this frame by taking out the path by string manipulation of the file name of the previous pages iamge and so forth.


          If you have any issues in writing this solution, post a concrete example with real data(i.e, name of the filename's and other details). So that we can create a script to provide a solution.



          • 2. Re: Can this be done?
            Colin Flashman Adobe Community Professional

            I'd do this as a data merge, rather than rely on InDesign to magically "trigger" the pictures to fall into place based on filenames etc.


            Set up the database so that each row has the following fields:


            @main pic      @linkedpic1     @linkedpic2     @linkedpic3   @linkedpic4    @linkedpic5   etc

            first1.jpg           shirt1.jpg         trouser1.jpg       tank1.jpg


            etc etc


            it will mean setting up a database in software such as excel, but this would be the way i'd tackle a project like this.

            • 3. Re: Can this be done?
              GD_lewis Level 1

              Hi Manan,


              Thank you very much for your reply. What you say sounds very promising and I have to admit that the thing stopping me was my ability to script! I wanted to make sure it was possible before pursuing it further. If we could make this happen though it would be quite amazing!


              So as you have requested I've uploaded a complete working example in an InDesign package to this location: http://cl.ly/0S2S3F0a081g



              Let me know if you think you can get it to work and how long it'll take to do. If you could have it working by Monday I think I could arrange some remuneration for your time.


              Many thanks,


              • 4. Re: Can this be done?
                GD_lewis Level 1

                Hi cdflash,


                Thanks also for your reply. If you have a look at the file that I've uploaded you'll see that there are multiple photos on each page and therefore we would need to be able to selectively trigger the script from within the document. Would your solution allow this to happen?


                Thanks again,


                • 5. Re: Can this be done?
                  Colin Flashman Adobe Community Professional



                  I've uploaded a sample of what can be accomplished using Data Merge to this URL: http://colecandoo.files.wordpress.com/2012/10/script_test_colly.pdf


                  The PDF contains a 3pp result generated exclusively out of Data Merge. If you look for the paperclip icon in the PDF, you will find all the assets used to do this. The key is the "untitled-1.txt" file which is used by data merge to reference the pictures in the merge.


                  As I said in my original post, I wouldn't rely on InDesign to magically "trigger" the pictures to fall into place based on filenames.


                  Data Merge can do some amazing things which I use commercially for direct mail campaigns. Check out this page on my blog http://wp.me/p1x3Yg-5b and have a look at the VDP topic on the same blog to see if any of the features there can be used in your project.


                  Bottom line though, is that InDesign is only putting the information from a Data Merge into formfields, it doesn't understand or parse it. To do the "magic" in a merge, that is done by the spreadsheet that generates the txt/csv file that indesign will reference, so a good knowledge of Excel; or google searches for doing what you want in excel are important.



                  • 6. Re: Can this be done?
                    -hans- Level 4



                    looking at the samplefile it seems, that the count of sketches may differ and then also the size of each on the spread ...

                    If this is true, you have to define rules for sizes and positions that should be used.


                    Colly's approach seems to be very good (as your layout seems to be quite simple) if you've got all the data ready.


                    If your just looking for a little helper. Try this snippet. It'll load all sketches of selected 'linked photographs' into the place gun (please select the rectangles, folder 'Sketches' has to be in the same folder as the indd-file)


                    //select one or more 'linked photographs' on a page, then run the script ...
                    #target Indesign
                    var currDoc = app.activeDocument;
                    if(!currDoc.saved){alert('Please save the document before running the script'), exit()};
                    var pathToSketches = currDoc.filePath.absoluteURI + '/Sketches/';
                    if(!Folder(pathToSketches).exists){alert(pathToSketches + 'does not exist'), exit()};
                    var currSel = app.selection;
                    function getSketches(sel) {
                        tmp = [];
                        for (var s = 0; s < sel.length;s++){
                            var rect = sel[s];
                            if(!rect.constructor.name === 'Rectangle'){alert('Part of selection is not Rectangle. Script aborted'); exit();}
                            var img = rect.images[0];
                           var imgName = img.itemLink.name;
                    var imgNameArray = imgName.split('_');
                    l = imgNameArray.length;
                    x = 0;
                    while(x < l-1){tmp.push(File(pathToSketches + imgNameArray[x].slice(0,4) + '.tif')); x++}
                        return cleanArray(tmp);
                    function cleanArray(array) {  
                      var obj = {}  
                      var list = []  
                      for (var i = 0; i < array.length; i++) {  
                        var obj = array[i]  
                        if (!list[obj]) {  
                          list[obj] = true  
                        return list  

                    Hans-Gerd Claßen