Copy link to clipboard
Copied
Hi,
I want to find the content based on its font bold.
I dono the syntax to find conent based on font.
Please any one help me on this.
Copy link to clipboard
Copied
Hi,
I think the following code will work
words = app.activeDocument.stories.everyItem().words.everyItem().getElements();
for(i=0; i<words.length; i++)
{
word = words;
if(word.fontStyle=="Bold")
{
// Your statement;
}
}
Copy link to clipboard
Copied
app.findTextPreference.fontStyle = "Bold"
myWhatEver.findText()
Same applies for findGrepPreference etc.
Copy link to clipboard
Copied
Just saw the previous suggestion.
It is normally (almost always) not a good idea to loop through contents when it can be avoided by useing findGrep and the like as it is much much slower
Copy link to clipboard
Copied
Hi,
Thanks for your suggestion.
Copy link to clipboard
Copied
Hi,
Thanks for your respose. I used the below code as you said, but it shows the below error as in Image.
var myDoc = app.activeDocument;
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreference.fontStyle = "Bold"
var boldCont = myDoc.findText();
alert(boldCont.length)
for(var cnt = 0 ; cnt < boldCont.length; cnt ++)
{
var selCont = boldCont[cnt]
selCont.select();
alert(selCont.contents+"\n"+app.selection[0].paragraphs[0].contents.length);
}
v
Copy link to clipboard
Copied
Hi,
There is a typo:
app.findTextPreference.fontStyle = "Bold";
should be
app.findTextPreferences.fontStyle = "Bold";
rgds
Copy link to clipboard
Copied
Hi,
Thanks for you help, it is working now ..
Copy link to clipboard
Copied
Pleasure,
Please designate correct and helpful appropriately
Trevor