Pdfmake: Multiple levels in ToC?

Created on 13 Jul 2018  路  6Comments  路  Source: bpampuch/pdfmake

Is it possible somehow to get header and subheaders on different levels in the table of contents?
Something like:

Table of contents:
Introduction
- Background
- About the project
- About the authors
Abstract
...

Been looking around and trying with the code but can't get it to work.

Most helpful comment

I want to add the dot in TOC. How can I do that? @karatekaneen

All 6 comments

i hope i understand you...

if your headers make use of a specific style you can iterate over the contents and just grep them together to create a ToC

Sorry but I now see I wasn't very clear.
I'm generating reports and I've got some major headers things like introduction and summary and so on. And within these major headers i've got subheaders so I want that the subheaders get indented one level. Attaching pic from word to show how I mean.
ahr0cdovl3d3dy5syxb0b3btywcuy29tl2ltywdlcy93cc9wdxjjac1hcgkvaw5jb250zw50lziwmtuvmtevdg9wlxdvcmqtdgfibgutb2yty29udgvudhmtmjuwedexnc5wbmc

So your problem is the indention? Why you don't manage that by margin?

You can use tocMargin for indentation. Is also possible to use tocStyle.

Example:

var dd = {
    content: [
        {
            toc: {
                title: {text: 'INDEX'},
            }
        },
        {
            text: 'Introduction',
            tocItem: true,
            tocStyle: {bold: true},
            pageBreak: 'before'
        },
        'Lorem ipsum dolor sit amet...',

        {
            text: 'Background',
            tocItem: true,
            tocMargin: [20, 0, 0, 0],
            pageBreak: 'before'
        },
        'Lorem ipsum dolor sit amet...',

        {
            text: 'About the project',
            tocItem: true,
            tocMargin: [20, 0, 0, 0],
            pageBreak: 'before'
        },
        'Lorem ipsum dolor sit amet...',

        {
            text: 'About the authors',
            tocItem: true,
            tocMargin: [20, 0, 0, 0],
            pageBreak: 'before'
        },
        'Lorem ipsum dolor sit amet...',

        {
            text: 'Abstract',
            tocItem: true,
            tocStyle: {bold: true},
            pageBreak: 'before'
        },
    ]
}

And see /examples/toc.js

I want to add the dot in TOC. How can I do that? @karatekaneen

i also want to add the dot in TOC. anyone can help me ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SummerSonnet picture SummerSonnet  路  3Comments

kumarandena picture kumarandena  路  3Comments

Masber picture Masber  路  3Comments

dgrice picture dgrice  路  3Comments

MathLavallee picture MathLavallee  路  3Comments