• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

noBreak for whole document

Explorer ,
Jun 05, 2017 Jun 05, 2017

Copy link to clipboard

Copied

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

TOPICS
Actions and scripting

Views

486

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 07, 2017 Jun 07, 2017

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 te

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

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.textItem.contents = layers.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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2017 Jun 07, 2017

Copy link to clipboard

Copied

bsf2017  wrote

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

No.

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines