5 Replies Latest reply on Apr 24, 2015 6:30 AM by W_J_T

    Is it possible to have dynamically scaled/aligned variable fields (like name + surname)?

    dood123

      Hi

       

      I have an ID card template in Illustrator which we fill in with dynamic data.

       

      I have some rows with more than one variable, for example:
      [name] [surname]

      Is it possible to set up the document so these fields are aligned dynamically depending on the variable content?
      Right now, if the name is too long it overlaps the surname box. And if it's too short it creates a wide gap between fields.

       

      Of course, I might join two fields to have something like [name_surname], but it's not always possible as sometimes these fields use different fonts etc.

       

      I was looking around for some solution, but I could not find anything...

       

      thanks, dan

        • 1. Re: Is it possible to have dynamically scaled/aligned variable fields (like name + surname)?
          Silly-V Adobe Community Professional

          If you only have 2 such fields, this could be worked-around by having 2 text frames, justified left and right so that they both push toward a common middle.
          Otherwise, it is possible to put a post-processing script which could do any number of things, into the action which will export the dataset.

          Such may be a script which duplicates the text (could be referenced by Note, or Name, etc) and uses some basic coordinate-based transformations to translate some of the fields to fit a desired layout. This could be performed on a special temporary layer, and every time the script runs for each dataset, it would try to look for a previous such layer in the document to remove its contents to clear the area for the current text items.

          I've not yet done this, but I'm willing to help if you can test it out.

          • 2. Re: Is it possible to have dynamically scaled/aligned variable fields (like name + surname)?
            dood123 Level 1

            thanks for this hint, but my problem is quite more complex than that.
            Ideally, I am looking for a solution to be used with more than 2 fields and in various configurations.
            For example:
            [fieldA] [fieldB] - both aligned to the left, right or center or justified left and right
            the same with more fields, too.

             

            I might try to compute somehow their positions, but I was hoping there is some in-built mechanism in Illustrator to do this automatically...

            • 3. Re: Is it possible to have dynamically scaled/aligned variable fields (like name + surname)?
              Qwertyfly... Level 4

              Is this being done with variables and an xml doc with all the data?

              Or is it a script you have that take info from a CSV type file.

               

              If you are using the second option then there may be solutions.

              the variable and XML method may be difficult.

               

              I have always used indesign for this as it is a great deal simpler and you have heaps of flexibility

              • 4. Re: Is it possible to have dynamically scaled/aligned variable fields (like name + surname)?
                Silly-V Adobe Community Professional

                Actually, if you use the XML method, there may be a solution in this workaround approach: You can have an intermediary data-processing 'layer' of text frames in a layer or group of your document, each text-frame being assigned to one XML variable. Keep this group or layer hidden from view by having it off the artboard, or behind a background. Then, in the actual text placeholders where you want your text displayed for view, write the preferred string with placeholders, or, better yet, use the note attributes feature to write the placeholder text with some-how delimited placeholders. When a data-set processing action processes the files, make sure to include a custom script which replaces the placeholder string with the contents of the individual variable-bound text frames. This would essentially make a compound-variable text body.

                A visual example is this:
                My placeholder text has this in the note: <<first_name>>, <<last_name>>

                So each time the dataset is processed, a script gets the contents of the first_name and last_name variables and replaces the placeholder string to produce a sample of "Bob, Smith".  Then you realize that this arrangement is actually not correct, it should be "<<last_name>>, <<first_name>>" , so you make the changes and run the whole thing again to get "Smith, Bob" .

                 

                Of course, I might join two fields to have something like [name_surname], but it's not always possible as sometimes these fields use different fonts etc.


                Thanks to Illustrator scripting being able to work on individual characters, I think it may be possible to style the compound placeholder text frame by first putting on the appropriate styles on your individual text frames, which the post-processing script can read the text properties of and assign them by going through the characterAttributes.

                • 5. Re: Is it possible to have dynamically scaled/aligned variable fields (like name + surname)?
                  W_J_T Level 4

                  dood123 wrote:

                   

                  Is it possible to have dynamically scaled/aligned variable fields?

                  • I have some rows with more than one variable, for example: [name] [surname]
                  • Is it possible to set up the document so these fields are aligned dynamically depending on the variable content?
                  • Right now, if the name is too long it overlaps the surname box. And if it's too short it creates a wide gap between fields.

                   

                  Maybe I am misunderstanding, but you mean such as this?

                  blah_yada.png