Highlighted

Unable to add [Basic Paragraph] when generating TOC

Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

Hi,

 

When generating a TOC, one of the styles I want to be able to add is the [Basic Paragraph] style in case no custom style has been used. I can add it when generating a TOC manually but it errors when I try to add this style in extendscript. Has anyone managed to acheive this? The relevant code is below:

 

myTOC.tocStyleEntries.add ({
formatStyle:"[Basic Paragraph]",
name:"[Basic Paragraph]",
level:1,
separator:"\t",
pageNumberPosition: PageNumberPosition.BEFORE_ENTRY,
});

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Stuart,

after more testing I found a way to apply the Basic Paragraph Style by name as value to tocStyleEntry.name.

You have to use the "international" string for this style. And that is:

 

 

"$ID/NormalParagraphStyle"

 

 

How did I find this one?

I ran app.findKeyStrings() on the name of paragraphStyles[0] paragraphStyles[1]:

 

 

// Returns an array:
app.findKeyStrings( app.documents[0].paragraphStyles[1].name );

 

 

Important Note 1:

app.findKeyStrings() always returns an array.

Length could be 0 when nothing is found or greater than one if one or more strings are found.

 

Important Note 2:

If you want to apply a paragraph style that is nested into a paragraph style group you have to use the following syntax for the string you apply to property name of the toc style entry:

 

 

"paragraph style group name:paragraph style name"

 

 

 

If the paragraph style is more than one group deep simply follow this rule:

 

 

"group-level-1 name:group-level-2 name:style name"

 

 

 

Regards,
Uwe Laubender

( ACP )

 

//EDITED

TOPICS
Scripting

Views

92

Likes

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

Unable to add [Basic Paragraph] when generating TOC

Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

Hi,

 

When generating a TOC, one of the styles I want to be able to add is the [Basic Paragraph] style in case no custom style has been used. I can add it when generating a TOC manually but it errors when I try to add this style in extendscript. Has anyone managed to acheive this? The relevant code is below:

 

myTOC.tocStyleEntries.add ({
formatStyle:"[Basic Paragraph]",
name:"[Basic Paragraph]",
level:1,
separator:"\t",
pageNumberPosition: PageNumberPosition.BEFORE_ENTRY,
});

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi Stuart,

after more testing I found a way to apply the Basic Paragraph Style by name as value to tocStyleEntry.name.

You have to use the "international" string for this style. And that is:

 

 

"$ID/NormalParagraphStyle"

 

 

How did I find this one?

I ran app.findKeyStrings() on the name of paragraphStyles[0] paragraphStyles[1]:

 

 

// Returns an array:
app.findKeyStrings( app.documents[0].paragraphStyles[1].name );

 

 

Important Note 1:

app.findKeyStrings() always returns an array.

Length could be 0 when nothing is found or greater than one if one or more strings are found.

 

Important Note 2:

If you want to apply a paragraph style that is nested into a paragraph style group you have to use the following syntax for the string you apply to property name of the toc style entry:

 

 

"paragraph style group name:paragraph style name"

 

 

 

If the paragraph style is more than one group deep simply follow this rule:

 

 

"group-level-1 name:group-level-2 name:style name"

 

 

 

Regards,
Uwe Laubender

( ACP )

 

//EDITED

TOPICS
Scripting

Views

93

Likes

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
Mar 27, 2020 0
Adobe Community Professional ,
Mar 27, 2020

Copy link to clipboard

Copied

Hi Stuart.

the basic paragraph style can be reached by its index as well.

You are trying this by its name.

 

This would assign a paragraph style object with index 1, that's always the basic paragraph style, and not a name:

formatStyle: app.documents[0].paragraphStyles[1] ,

 

I did not test this, but I hope it helps…

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Reply
Loading...
Mar 27, 2020 0
Community Beginner ,
Mar 29, 2020

Copy link to clipboard

Copied

Hi Uwe,

Thank you for this. It works for the 'formatStyle' property but not for the 'name' property which seems to accept names only. I'm also wondering if overset text can be included in a script generated TOC as I can't find any reference to this.

Any help is much appreciated.

 

Regards

Stuart

Likes

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
Reply
Loading...
Mar 29, 2020 0
Adobe Community Professional ,
Mar 29, 2020

Copy link to clipboard

Copied

The name property?
That's only the name of the TOC style itself.

I think, you can name it like you want.

 

Sorry. After reading your code again, I see, that you talk about the name of a tocStyle entry.

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Reply
Loading...
Mar 29, 2020 0
Adobe Community Professional ,
Mar 30, 2020

Copy link to clipboard

Copied

Hi Stuart,

after more testing I found a way to apply the Basic Paragraph Style by name as value to tocStyleEntry.name.

You have to use the "international" string for this style. And that is:

 

 

"$ID/NormalParagraphStyle"

 

 

How did I find this one?

I ran app.findKeyStrings() on the name of paragraphStyles[0] paragraphStyles[1]:

 

 

// Returns an array:
app.findKeyStrings( app.documents[0].paragraphStyles[1].name );

 

 

Important Note 1:

app.findKeyStrings() always returns an array.

Length could be 0 when nothing is found or greater than one if one or more strings are found.

 

Important Note 2:

If you want to apply a paragraph style that is nested into a paragraph style group you have to use the following syntax for the string you apply to property name of the toc style entry:

 

 

"paragraph style group name:paragraph style name"

 

 

 

If the paragraph style is more than one group deep simply follow this rule:

 

 

"group-level-1 name:group-level-2 name:style name"

 

 

 

Regards,
Uwe Laubender

( ACP )

 

//EDITED

Likes

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
Reply
Loading...
Mar 30, 2020 1
Community Beginner ,
Apr 16, 2020

Copy link to clipboard

Copied

Hi Uwe,

Apologies for the delay in responding. Thank you so much for taking the trouble to find this out, it has helped enormously.

 

Regards

Stuart

Likes

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
Reply
Loading...
Apr 16, 2020 0