Skip to main content
Inspiring
November 22, 2023
Answered

Applying paragraph style using script but bold and italic formatting lost

  • November 22, 2023
  • 2 replies
  • 496 views

In the following script, the formatting of bold and italic words in text frame changed to normal/plain font.

Any suggestion to retain it without creating bold and italic character style sheets for it and looping each paragraph.

var myDoc = app.activeDocument;

myFrame = myDoc.textFrames.itemByName("virender");

myFrame.parentStory.paragraphs.everyItem().appliedParagraphStyle = "Body_text";

This topic has been closed for replies.
Correct answer Laubender

Hi @virender_CTS ,

see into method applyParagraphSyle() that comes with some options:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Text.html#d1e459465__d1e465769

 

The first argument requires the style object itself, not just the name, the second one is the one you perhaps are after.

Try to set "clearingOverrides" to false.

 

myFrame.parentStory.texts[0].applyParagraphStyle
(
app.activeDocument.paragraphStyles.itemByName( "Body_text" ) ,
false
);

 

Regards,
Uwe Laubender
( Adobe Community Expert )

2 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
November 22, 2023

Hi @virender_CTS ,

see into method applyParagraphSyle() that comes with some options:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Text.html#d1e459465__d1e465769

 

The first argument requires the style object itself, not just the name, the second one is the one you perhaps are after.

Try to set "clearingOverrides" to false.

 

myFrame.parentStory.texts[0].applyParagraphStyle
(
app.activeDocument.paragraphStyles.itemByName( "Body_text" ) ,
false
);

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Inspiring
November 22, 2023

Hi Uwe,

Vielen Dank (many thanks), this feature I was not aware of. It is working fine except for two paragraphs which are completely bold. Even when I select the complete text and then apply style using without script then also those two sentences bold converted to normal font.

Community Expert
November 22, 2023

Hi @virender_CTS ,

check if there is a character style applied to the paragraphs with text all in bold.

Hm. The question here is if the formatting is really intended…

Without having the InDesign document at hand, it's hard to see where the issue lies.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Robert at ID-Tasker
Legend
November 22, 2023

Looks like a side effect of this is Clear Style Overrides is applied as well... 

 

Why can't you create and apply CharStyles first? Text imported from WORD and you are cleaning it? 

 

https://community.adobe.com/t5/indesign-discussions/stuck-with-ms-word-style-and-style-mapping-on-import/m-p/14249995#M551626