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
1 Correct answer
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
...
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
Copy link to clipboard
Copied
Hi Manan, Thank you for your quick reply. 🙂

