Modifying "style" of .docx TOC using javascript (docx-js)

Viewed 324

Question:

Following this tutorial, https://docx.js.org/#/usage/table-of-contents, I would like to do the following two things:

  1. Change the font & size of entries in the table as the default Times New Roman - 10 is too small.
  2. Remove the "leading dots" from entries to page numbers: a.......1 to a 1

What I tried (with no success):

  1. All my entries are based on Heading1 so their level is 1. stylesWithLevels: [new StyleLevel("Style", 1)]. This produces no change whatsoever.

  2. entryAndPageNumberSeparator: "\t" gives leading dots (a.......1), while entryAndPageNumberSeparator: " " gives a 1. I tried other combinations like entryAndPageNumberSeparator: " \t" to no avail. It seems like only the first character is taken into consideration.

Both of these were tested individually with a working TOC (modified from the above tutorial):

new TableOfContents("Example", {
  hyperlink: true,
  headingStyleRange: "1-1",
}),
0 Answers
Related