From 287b6e29caf64b6dbec1c4de0cbb6b6a1dba1a0a Mon Sep 17 00:00:00 2001 From: Adrian-George Bostan Date: Thu, 4 Oct 2018 18:00:43 +0300 Subject: [PATCH] Add SetTOC method to the creator --- pdf/creator/creator.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pdf/creator/creator.go b/pdf/creator/creator.go index 3e5b8779..89b15a37 100644 --- a/pdf/creator/creator.go +++ b/pdf/creator/creator.go @@ -142,6 +142,16 @@ func (c *Creator) TOC() *TOC { return c.toc } +// SetTOC sets the table of content component of the creator. +// This method should be used when building a custom table of contents. +func (c *Creator) SetTOC(toc *TOC) { + if toc == nil { + return + } + + c.toc = toc +} + func (c *Creator) setActivePage(p *model.PdfPage) { c.activePage = p } @@ -293,8 +303,8 @@ func (c *Creator) Context() DrawContext { return c.context } -// Call before writing out. Takes care of adding headers and footers, as well as generating front -// Page and table of contents. +// Call before writing out. Takes care of adding headers and footers, as well +// as generating front Page and table of contents. func (c *Creator) finalize() error { totPages := len(c.pages)