Highlighted

Apply character format using ExtendScript

Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

I need to apply a character tag to specific words within a specific paragraph tag throughout a document. For example, if a paragraph is tagged CaptionFigure, the words "Figure F1" (using regix -- (?:Figure) ((F)(\d+)) ) should be made bold. Can someone please help me with a script for this? Thanks!

 

TOPICS
Scripting

Views

55

Likes

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

Apply character format using ExtendScript

Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

I need to apply a character tag to specific words within a specific paragraph tag throughout a document. For example, if a paragraph is tagged CaptionFigure, the words "Figure F1" (using regix -- (?:Figure) ((F)(\d+)) ) should be made bold. Can someone please help me with a script for this? Thanks!

 

TOPICS
Scripting

Views

56

Likes

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
Jun 24, 2020 0
Adobe Community Professional ,
Jun 24, 2020

Copy link to clipboard

Copied

function applyCharFmt (textRange, name, doc) {
    
    var charFmt, prop;
    
    // See if the character format exists.
    charFmt = doc.GetNamedCharFmt (name);
    if (charFmt.ObjectValid () === 1) {
        doc.SetTextProps (textRange, charFmt.GetProps ());
    }
    else { 
        // If not, just apply the name so that the text
        // will update when you import formts from a template.
        prop = new PropVal ();
        prop.propIdent.num = Constants.FP_CharTag;
        prop.propVal.valType = Constants.FT_String;
        prop.propVal.sval = name;
        doc.SetTextPropVal (textRange, prop);
    }
}

Likes

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
Reply
Loading...
Jun 24, 2020 0
jmyers2 LATEST
Explorer ,
Jun 25, 2020

Copy link to clipboard

Copied

Thank you!

Likes

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
Reply
Loading...
Jun 25, 2020 0