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

How to create a paragraph with difference font format by script/DOM?

Community Beginner ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Dear All,

 

Is it possible to create a paragraph by Indesign script / DOM as below format?

 

Chapter One - Sample

 

Regards!
Brian 

 

TOPICS
How to , Scripting , SDK

Views

231

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

correct answers 1 Correct answer

Community Expert , Nov 15, 2022 Nov 15, 2022

Hi @BrianLam2022,

Yes we can do that using scripting and much more. However, there are lots of ways to get this done, a simple approach is to use styles and apply them explicitly.

Create two styles, CS1(character style) for red color text, PS1(paragraph style) for the remaining text. Then create a text frame, select it and execute the following code

 

 

var a = app.selection[0]
a.insertionPoints[-1].appliedParagraphStyle = "PS1"
a.insertionPoints[-1].appliedCharacterStyle = "CS1"
a.contents = "C
...

Votes

Translate

Translate
Community Expert ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

Hi @BrianLam2022,

Yes we can do that using scripting and much more. However, there are lots of ways to get this done, a simple approach is to use styles and apply them explicitly.

Create two styles, CS1(character style) for red color text, PS1(paragraph style) for the remaining text. Then create a text frame, select it and execute the following code

 

 

var a = app.selection[0]
a.insertionPoints[-1].appliedParagraphStyle = "PS1"
a.insertionPoints[-1].appliedCharacterStyle = "CS1"
a.contents = "Chapter One - "
a.insertionPoints[-1].appliedCharacterStyle = app.documents[0].characterStyles[0]
a.insertionPoints[-1].contents = "Sample"

 

 

In addition to this you could also use Grep style if you have some defined logic to identify the text that has to be applied with the character style.

-Manan

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 Beginner ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

LATEST

Hi Manan, Thank you for your quick reply. 🙂

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