Skip to content

Working with Heading, how to find the level ? #2107

Answered by Willena
Willena asked this question in Q&A
Discussion options

You must be logged in to vote

I finally found a way to get something close to what I needed. It involves using properties from the ParaPr value generated by the ToJSON() method.

Here is a sample code

const firstTitle = Api.GetDocument().GetAllHeadingParagraphs()[0]
const titleLevel = JSON.parse(firstTitle.GetStyle().GetParaPr().ToJSON()).outlineLvl
// Heading 1 is 0, Heading 2 is 1, ...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Willena
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant