Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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]
Copy link to clipboard
Copied
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?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now