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

Applying paragraph style using script but bold and italic formatting lost

Engaged ,
Nov 22, 2023 Nov 22, 2023

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";

TOPICS
Scripting
331
Translate
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 22, 2023 Nov 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 Comm

...
Translate
LEGEND ,
Nov 22, 2023 Nov 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-im...

 

Translate
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 ,
Nov 22, 2023 Nov 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 )

Translate
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
Engaged ,
Nov 22, 2023 Nov 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.

Translate
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 ,
Nov 22, 2023 Nov 22, 2023
LATEST

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 )

Translate
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