4 Replies Latest reply on Mar 31, 2010 4:03 PM by A Vit

    Can't insert column break

    A Vit

      I'm trying to insert a column break into my story, but it comes out as a regular paragraph break. How can I do this?

       

      story.insertionPoints[-1].contents = SpecialCharacters.columnBreak;

       

      This is InDesign CS4 on Mac.

        • 1. Re: Can't insert column break
          [Jongware] Most Valuable Participant

          Works for me... ???

           

          Try this one line script, in a new, blank document, with only one text frame in it:

           

           

          app.activeDocument.stories[0].insertionPoints[-1].contents = SpecialCharacters.columnBreak;

          On my CS4/Mac it does insert a column break.
          1 person found this helpful
          • 2. Re: Can't insert column break
            A Vit Level 1

            Thanks, I figured it out. Here's what I was doing:

             

            story.insertionPoints[-1].contents = SpecialCharacters.columnBreak; story.contents += realtorName + "  " + realtorPhone;

            I was using += to append text throughout, which doesn't work for SpecialCharacters, so I changed only that one row to use the insertionPoint contents. (If you try it with +=, you'll get the numeric character code.)

            Changing it to this did the trick:

            story.insertionPoints[-1].contents = SpecialCharacters.columnBreak; story.insertionPoints[-1].contents = realtorName + "  " + realtorPhone;

            Other uses of += are fine, just the one following the special character breaks it. Not sure why.

            • 3. Re: Can't insert column break
              [Jongware] Most Valuable Participant

              At least I can explain that.

               

              "Contents" is not really an existing property of the main Text object. It behaves just like a regular text string in Javascript (and probably in other languages as well), but that doesn't mean it is a simple string. I think reading from and writing to it are caught at a fairly low-level position in the DOM object tree and translated internally to mess with the "real" text object, so it's fully transparent to the programmer.

               

              But with a noticeable exception! Javascript strings are fully Unicode-aware, so you can read and write any Unicode character in the string. However, InDesign needs more than simple Unicode characters. I think most of its special spaces are translated into the correct codes, but ID has lots and lots more stuff that does not exist in UC: special markers such as variables and the page number thingies, flush spaces, and, of course, all of its different kinds of returns: page, column, and frame breaks.

               

              So how can you address these oddball codes in a Javascript string? You can't. Inserting a SpecialCharacter code "into" a text.contents must be another kind of internal "hack" (in a pure positive way). You can see for yourself if you stuff in your Column Break and then try to read it back -- not as a single character (because the translation works both ways; you'd simply get a SpecialCharacters.columnBreak value back), but with a substring, for example. You will see InDesign hands you back a totally normal hard return.

              • 4. Re: Can't insert column break
                A Vit Level 1

                Thanks for the insight. That reply totally deserves the gold star!