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

How to iterate a story to find if a characterstyle is applied to its textranges?

New Here ,
Apr 18, 2013 Apr 18, 2013

Does source like below work?

characterStyle.parent == theStory.textRanges

One more questions is if there might be a CharacterAttribute who belongs no characterstyle? Can I iterate charaterstyles to know all the font, bold .. information for all teh textranges?

Message was edited by: caterpillarjin

TOPICS
Scripting
1.1K
Translate
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
Adobe
Community Expert ,
Apr 18, 2013 Apr 18, 2013

Create a textframe with min 1 character and run the following script.

Perhaps it's a little bit helpful.

// characterAttributes

var aDoc  = app.activeDocument;

var aChar = aDoc.textFrames[0].characters[0];

alert (aChar.characterAttributes.size)

alert (aChar.characterAttributes.alignment)

alert(aDoc.characterStyles.length)

alert(aDoc.characterStyles[0].characterAttributes.size)

In ESTK OMV you can see much more character attributes.

Translate
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 ,
Apr 19, 2013 Apr 19, 2013

this covers the first question, select a text frame before running

var idoc = app.activeDocument;

var sel = idoc.selection[0];

alert(sel.textRange.characterStyles[0].name); // returns the first character style

Translate
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
New Here ,
Apr 21, 2013 Apr 21, 2013

The problem is I want to extract all text in a doc and get information like font, bold or so for every single text. For example:

bold: this is the text.

Instead of checking character attribute of each character, I'm think about iterate every characterstyle. So I need to know the parent of each characterstyle, right?

Translate
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 ,
Apr 22, 2013 Apr 22, 2013

Do you really mean characterstyle or paragraphstyle?

For character style, you have to loop through all the characters. And every char "without" characterstyle yet still have one  -->  aDoc.characterStyles[0]

Translate
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
New Here ,
Apr 22, 2013 Apr 22, 2013
LATEST

How does characterStyle tell from each other? I found the name of these characterStyles all the same.

Are there any place in a doc used to save these characterStyles or characterAttributes? Also, I found the parent of these characterStyles the same. Then how can I know who does these characterStyle belong to?

Translate
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