Ist es möglich, mit pdfmake eine Inhaltsverzeichnisstabelle (TOC) zu erstellen? Die Bibliothek wird die PDF für mich generieren, aber ich habe keine Ahnung, auf welcher Seite ein bestimmtes Objekt gerendert wird. Dies hängt natürlich von der Seitengröße, Ausrichtung usw. ab. Einige Inhalte werden auf eine nächste Seite geleitet. Ich kann nicht sehen, wie ich im Voraus berechnen soll, wo ein Kapitel endet.Wie erstellt man ein Inhaltsverzeichnis mit pdfmake?
dieses Dokument Definition vor:
var dd = {
footer: function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; },
content: [
'Table of contents\n\n',
'Chapter 1 ....... ?',
'Chapter 2 ....... ?',
'Chapter 3 ....... ?',
'Chapter 4 ....... ?',
{
text: '',
pageBreak: 'after'
},
{
text: 'Chapter 1: is on page 2',
pageBreak: 'after'
},
{
stack: [
'Chapter 2: is on page 3\n',
'A LOT OF ROWS 2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n',
'A LOT OF ROWS 2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n',
'A LOT OF ROWS 2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n',
'A LOT OF ROWS 2\nWill go to the next page if this line contains a lot of text. Will go to the next page if this line contains a lot of text. Will go to the next page if this line contains a lot of text.'
],
pageBreak: 'after'
},
{
text: 'chapter 3: is on page 5',
pageBreak: 'after'
},
{
text: 'chapter 4: is on page 6'
},
]
}
Die einfachste wat zu Test ist dieses dd Objekt auf dem Spielplatz einzufügen: http://pdfmake.org/playground.html
Alle Ideen, wie ein Inhaltsverzeichnis erstellen?