Formatting text into styles
Hi,
I need to find all formatting text into character styles, i used the below code. it's working fine.
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.fontStyle = "Bold"
app.changeTextPreferences.appliedCharacterStyle = "bold";
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Italic"
app.changeTextPreferences.appliedCharacterStyle = "italic";
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Bold Italic"
app.changeTextPreferences.appliedCharacterStyle = "bolditalic";
app.documents.item(0).changeText();
app.findTextPreferences.underline=true;
app.changeTextPreferences.appliedCharacterStyle = "underline";
app.documents.item(0).changeText();
app.findTextPreferences=app.changeTextPreferences=null;
alert("Characer Styles are applied for all Font styles")
Incase (Bold, Italic, Bold italic) + underline text comes, it will not work. so i created the character styles for boldwithunderline, italicwithunderline, bolditalicwithunderline.
Can you anyone please include the below condition?
Bold = "bold"
Italic = "italic"
Bold Italic = "bolditalic"
Normal text + underline = "underline"
Bold + underline = "boldunderline"
Italic + underline = "italicunderline"
Bold Italic + underline = "bolditalicunderline"
Is the below code is correct? if not please suggest.
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.fontStyle = "Bold"
app.changeTextPreferences.appliedCharacterStyle = "bold";
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Italic"
app.changeTextPreferences.appliedCharacterStyle = "italic";
app.documents.item(0).changeText();
app.findTextPreferences.fontStyle = "Bold Italic"
app.changeTextPreferences.appliedCharacterStyle = "bolditalic";
app.documents.item(0).changeText();
alert("Characer Styles are applied for all Font styles")
if((app.findTextPreferences.fontStyle = "Bold") && (app.findTextPreferences.underline=true) == true)
{
app.changeTextPreferences.appliedCharacterStyle = "boldunderline";
}
else if((app.findTextPreferences.fontStyle = "Italic") && (app.findTextPreferences.underline=true) == true)
{
app.changeTextPreferences.appliedCharacterStyle = "italicunderline";
}
else if((app.findTextPreferences.fontStyle = "Bold Italic") && (app.findTextPreferences.underline=true) == true)
{
app.changeTextPreferences.appliedCharacterStyle = "bolditalicunderline";
}
Regards,
Velu