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

Find text based on its font "Bold"

Contributor ,
Feb 11, 2013 Feb 11, 2013

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.

Screen shot 2013-02-11 at 5.29.32 PM.png

TOPICS
Scripting

Views

875

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 ,
Feb 11, 2013 Feb 11, 2013

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;

    }

}

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
Guru ,
Feb 11, 2013 Feb 11, 2013

Copy link to clipboard

Copied

app.findTextPreference.fontStyle = "Bold"

myWhatEver.findText()

Same applies for findGrepPreference etc.

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
Guru ,
Feb 11, 2013 Feb 11, 2013

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

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 ,
Feb 11, 2013 Feb 11, 2013

Copy link to clipboard

Copied

Hi,

Thanks for your suggestion.

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
Contributor ,
Feb 11, 2013 Feb 11, 2013

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);

}

Screen shot 2013-02-12 at 9.48.31 AM.pngv

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
Mentor ,
Feb 11, 2013 Feb 11, 2013

Copy link to clipboard

Copied

Hi,

There is a typo:

app.findTextPreference.fontStyle = "Bold";

should be

app.findTextPreferences.fontStyle = "Bold";

rgds

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
Contributor ,
Feb 13, 2013 Feb 13, 2013

Copy link to clipboard

Copied

Hi,

Thanks for you help, it is working now ..

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
Guru ,
Feb 13, 2013 Feb 13, 2013

Copy link to clipboard

Copied

LATEST

Pleasure,

Please designate correct and helpful appropriately

Trevor

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