Skip to main content
FarzanaA
Inspiring
January 22, 2026
質問

Update font size and leading for the Paragraph style which is based on another paragraph Style

  • January 22, 2026
  • 返信数 3.
  • 119 ビュー

Hello All,

I need a help. I am trying to update font size and leading of a paragraph style which is based on some other style. The font size and leading are set on the parent paragraph style which I want to decouple it.

For e.g. Paragraph style "aa" based on "BB" or "Basic Paragraph Style". The font size is set in  "BB" or "Basic Paragraph Style". But don't want to modify that and only update "aa" style.

 

I tried following Javascript through my C++ code

var mydoc = app.documents.item(0);
var paragraphStyle = mydoc.paragraphStyles.itemByName(\'" + sParaStyleName + "\');
paragraphStyle.properties = {
    pointSize:11,
    leading:15,
};

Also tried C++ code

InterfacePtr<ITextAttrRealNumber> PointSizeAttr((ITextAttrRealNumber*)(textAttr->QueryByClassID(kTextAttrPointSizeBoss, IID_ITEXTATTRREALNUMBER)));
if (PointSizeAttr == nil)
return;
 
PointSizeAttr->SetRealNumber(11);
InterfacePtr<ICommand> newStyleCmd(Utils<IStyleUtils>()->CreateEditStyleCmd(iStyleInfo));

 ErrorCode result = CmdUtils::ProcessCommand(newStyleCmd);

if (result != kSuccess)
{
    ASSERT_FAIL("newStyleCmd failed");
    return;
}
same for Leading. But it is not working.
Can someone please help.
 
Thank you all in advance
Farzana

返信数 3

Inspiring
January 26, 2026

Hi @FarzanaA ,

 

Refer the code snippet for modifying exixsting style properties -

 

 

InterfacePtr<ITextAttrRealNumber> fontSize(CreateObject2<ITextAttrRealNumber>(kTextAttrPointSizeBoss));
fontSize->SetRealNumber(12.0);			
InterfacePtr<IStyleInfo> iStyleInfo(styleUIDRef, UseDefaultIID());
InterfacePtr<ICommand> editStyleCmd(Utils<IStyleUtils>()->CreateEditStyleCmd(iStyleInfo, fontSize));
CmdUtils::ProcessCommand(editStyleCmd);

// To apply multiple attributes -

InterfacePtr<ITextAttrRealNumber> fontSize(CreateObject2<ITextAttrRealNumber>(kTextAttrPointSizeBoss));
fontSize->SetRealNumber(12.0);			
InterfacePtr<IStyleInfo> iStyleInfo(styleUIDRef, UseDefaultIID());

// add multiple attributes -
AddAttributeList addAttrList(new AttributeBossList);
addAttrList->ApplyAttribute(fontSize);

InterfacePtr<ICommand> editStyleCmd(Utils<IStyleUtils>()->CreateEditStyleCmd(iStyleInfo, addAttrList));
CmdUtils::ProcessCommand(editStyleCmd);

 

 

- Rahul Rastogi

Adobe InDesign C++ Custom Plugins Architect

FarzanaA
FarzanaA作成者
Inspiring
January 23, 2026

Hello,

Still not working. I tried with getting all paragraph styles in loop but same result. no change.

As far as the paragraphStyleGroups its giving 0 length.

 

And I will have to insert quotes because its a variable I am passing from C++ to Javascript.

 

Thanks  & Regards

m1b
Community Expert
Community Expert
January 23, 2026

Does the pure ExtendScript code work as expected? For example:

 

var mydoc = app.documents.item(0);
var paragraphStyle = mydoc.paragraphStyles.itemByName('Insert Actual Name Here');

if (!paragraphStyle.isValid) {
    alert('Not found.');
}
else {
    paragraphStyle.properties = {
        pointSize: 11,
        leading: 15,
    };
}

 

If this works, then we know it isn't something weird about your document or style, and is something to do with the C++/ExtendScript crossover? That's out of my wheelhouse unfortunately because I don't know C++ or the SDK.

 

When you say "I will have to insert quotes because its a variable I am passing from C++ to Javascript" I think that means that you are building the ExtendScript or Javascript code as a string from C++. So one approach would be to output the resulting string (code) to a text file and check that runs correctly as pure ExtendScript. This would rule out issues with the string building part.

m1b
Community Expert
Community Expert
January 23, 2026

@Dirk Becker does this question fall in your wheelhouse at all?

Peter Kahrel
Community Expert
Community Expert
January 22, 2026

Maybe drop the quotes from

 

mydoc.paragraphStyles.itemByName(\'" + sParaStyleName + "\');

 

 

m1b
Community Expert
Community Expert
January 23, 2026

Also note that

 

mydoc.paragraphStyles.itemByName(sParaStyleName)

 

only searches in the root level of the document's paragraph styles. If your target style is inside a style group, it won't be found. You must target the style via its group(s), eg.

 

mydoc.paragraphStyleGroups.itemByName('Text Styles').paragraphStyles.itemByName('Body Text')

 

 or, alternatively, iterate over

 

mydoc.allParagraphStyles

 

which is a normal Array.

FarzanaA
FarzanaA作成者
Inspiring
January 23, 2026

Thank you so much will definitely try both the options. by the way forgot to mention this issue I am getting is on Indesign Server. But will try and update.

Thanks once again