4 Replies Latest reply on May 6, 2017 6:14 AM by Steve Werner

    JavaScript code for customisable book


      Hi all,


      Lone time Adobe user just getting into scripting here. I have been teaching myself the basics, and it's going pretty well, but I feel it would be a lot faster to ask for some help here.


      I am am writing a book that will need to:


      1) put a different name for the character in each book (so finding whatever I typed as the placeholder and replacing it with a name throughout the whole document)


      2) re-link lots of images. The idea is that there will be placeholder graphics throughout the book but I'll have a library of different character graphics I'll want to re-link / replace in each book. These are all created in the same location in Illustrator so will drop in exactly in the right place



      So I'm looking for JavaScript code, or help with writing it, that looks at a set of parameters someone sent me (like name, hair colour etc.), replaces text and re-links images to the appropriate ones in the library, then exports as a PDF ready for print. Ideally, I'll need the script to go through multiple sets of parameters (different people with different names, hair colours etc.) and do the above for each.


      Its a big task I know, but any assistance from anyone, even with only a component of this, would be really useful and greatly appreciated.


      Thanks  advance!

        • 1. Re: JavaScript code for customisable book
          Obi-wan Kenobi Level 5



          For moderators: This thread should be placed into "InDesign Scripting" forum!



          • 2. Re: JavaScript code for customisable book
            [Jongware] Most Valuable Participant

            You don't really need a script to do all of this.


            1. To globally "replace" a name or some other text, make it a Text Variable.


            2. To globally replace a set of images, do the following:


            a. Put all of the variable images inside a folder of their own.

            b. For variants, create a new folder for each and put the variant images in this. Make sure the filenames match those in the other folder (and, ideally, their file type and size).

            c. To quickly swap the images, Relink your images to this new folder.

            • 3. Re: JavaScript code for customisable book
              Bhazakhain Level 1

              Hi there,


              Thanks for this. Yes it's really easy to Find & Replace text and relink to folders so they automatically update all same-named links, but the issue is that we're anticipating quite a lot of variations in a short timeframe so to save doing this document by document myself, I'm ideally looking to write a script to do this process automatically by itself many times over, depending on data that's put in. Ideally opening the document, doing the changes, Saving As and exporting as PDF, then moving onto the next version of the document.


              The input data would be in an identical format (order form), probably in an email inbox, but have a different name, hair colour, eye colour etc.

              • 4. Re: JavaScript code for customisable book
                Steve Werner Adobe Community Professional & MVP

                Moving to InDesign Scripting