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

How can i create paragraph or character style using javascript

Guest
Mar 05, 2012 Mar 05, 2012

Copy link to clipboard

Copied

Hi all,

I  have doubt in create a paragraph style or character style using javascript.

This is the script i am using write now:

app.findTextPreferences.findWhat = NothingEnum.nothing;

app.changeTextPreferences.changeTo = NothingEnum.nothing;

app.findTextPreferences.fontStyle = "Italic"

app.changeTextPreferences.appliedCharacterStyle = "cs_italic";

app.documents.item(0).changeText();

What the script is exactly doing is if the fontstyle is "Italic" means it automatically apply "cs_italic" style, which  i already  created in the character style pallette.

But what i want is if the fontstyle is (Italic, Bold) means it automatically create a character style related to their fonts after that apply over their styles.

I am new to forum and javascript.

Thanks in advance.....

TOPICS
Scripting

Views

1.8K

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
People's Champ ,
Mar 05, 2012 Mar 05, 2012

Copy link to clipboard

Copied

Not exactly sure what you're trying to do, but the line in bold is

wrong. Try this:

app.changeTextPreferences.appliedCharacterStyle =

myDoc.characterStyles.itemByName("cs_italic");

where myDoc is a reference to the document you working with (often this

will be app.activeDocument )

If your character style is in a group it's a little more complicated:

myDoc.characterStyleGroups.itemByName("myGroupName").characterStyles.itemByName("cs_italic");

Ariel

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
Community Expert ,
Mar 05, 2012 Mar 05, 2012

Copy link to clipboard

Copied

It's easy if you know how. A ParagraphStyle is part of your document's paragraphStyles property. The paragraphStyles property is of type ParagraphStyles (plural), and that object has a method called 'add': http://jongware.mit.edu/idcsjs5.5/pc_ParagraphStyles.html#add

So to add a paragraph style, you would use

pStyle = app.activeDocument.paragraphStyles.add();

and then set your new style's properties one at a time. The same goes for Character Styles, and for lots of other base document properties as well, from TextFrames to Hyperlinks to Colors.

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 ,
Nov 08, 2017 Nov 08, 2017

Copy link to clipboard

Copied

Hi.

I need a script that create a character style with these proprieties:

General / Based [none]

Basic Character Formats [none]

Advanced Character Format / Language [no language]

Character Color [none]

Open Type Features [none]

Underline Options [none]

Strikethrough [none]

Export tagging / ePUB and HTML / Tag [automatic]

Could you help me?

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
LEGEND ,
Nov 08, 2017 Nov 08, 2017

Copy link to clipboard

Copied

Could you pay somebody for that?

(^/)

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
Advocate ,
Nov 09, 2017 Nov 09, 2017

Copy link to clipboard

Copied

LATEST

You will find everything you need to know..

https://www.indesignjs.de/extendscriptAPI/indesign10/

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 ,
Nov 08, 2017 Nov 08, 2017

Copy link to clipboard

Copied

Hi.

I need a script that create a character style with these proprieties:

General / Based [none]

Basic Character Formats [none]

Advanced Character Format / Language [no language]

Character Color [none]

Open Type Features [none]

Underline Options [none]

Strikethrough [none]

Export tagging / ePUB and HTML / Tag [automatic]

Is it possible?

Anywhere can help me?

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