3 Replies Latest reply on Jun 8, 2017 11:28 AM by bsf2017

    noBreak for whole document

    bsf2017

      Hi,

       

      I'd like to write a JavaScript for turning the line breaks off for a whole document. Same with hyphenation.

       

      I'm thinking something like this:

       

      app.activeDocument.layers.textItems.noBreak = true;
      app.activedocument.layers.testItems.hyphenation = false;

       

      I am more familiar with InDesign which has a term call everyItem(). Is there such a thing for Photoshop?

      Can this be done?

       

      Thanks

      Beate

        • 1. Re: noBreak for whole document
          Laubender Adobe Community Professional & MVP

          Hi Beate,

           

          could you post a screenshot of before and after running a potential script?

          The text cursor should be positioned into the text.

           

          From my limited knowledge on PhotoShop scripting:

           

          textItem.kind == TextType.PARAGRAPHTEXT

          Example for hyphenated text. noBreak is false, hyphenation is true:

           

          PSD-TextType.PARAGRAPHTEXT.png

          If you set noBreak to true all contents will optically vanish. It's contents is still there, but in overset.

          Unless you increased the width of the frame in advance so that all text fits to one line.

           

          So setting text to noBreak = true is no good idea at all.

           

          textItem.kind == TextType.POINTTEXT

          Convert the example above to TextType.POINTTEXT.

           

          No hyphenation exists.

          Just text that perhaps looks like it is hyphenated.

           

          Result is a dash plus a paragraph sign as substitute for the hyphen in the example above:

           

          PSD-TextType.POINTTEXT.png

           


          In this case you would convert back to TextType.PARAGRAPHTEXT and want to get rid of the faux hyphen and the paragraph sign. Increase the width of the frame that all text fits on a line.

           

          Example after converting back to TextType.PARAGRAPHTEXT:

           

          PSD-TextType.POINTTEXT-converted-to-PARAGRAPHTEXT.png

           

          The problem:

          You cannot be sure, that a dash followed by a paragraph sign is always meant as a hyphen.
          In a lot of cases, yes, but not in all cases.

           

          See into property contents of textItem that returns a string.
          You can manipulate that with a regular expression doing a string operation with method replace() and assign the new contents if you do a loop on all relevant artLayers.

           

          layers[n].textItem.contents = layers[n].textItem.contents.replace(/-\r/g,"");
          

           

          If you want to omit cases, you can do a more elaborate regular expression than the one above.

           

          Here a link to a clever function that recursively traverses all layers and stores them in an array:

          c.pfaffenbichler :

          Re: Layer Sets (groups)

           

          ( Tested with ExtendScript on PhotoShop CS6 on Mac OSX 10.6.8. )

           

          Regards,
          Uwe

          • 2. Re: noBreak for whole document
            Laubender Adobe Community Professional & MVP

            bsf2017  wrote

            … I am more familiar with InDesign which has a term call everyItem(). Is there such a thing for Photoshop? …

            No.

             

            Regards,
            Uwe

            • 3. Re: noBreak for whole document
              bsf2017 Level 1

              Pfaffenbichler's script of grabbing the sublayers did the trick. Thanks so much!