mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-01 22:17:29 +08:00
Allow adding an external outline tree to the creator (#106)
This commit is contained in:
parent
3de3705eb2
commit
2189002435
@ -54,6 +54,9 @@ type Creator struct {
|
|||||||
// Outline.
|
// Outline.
|
||||||
outline *model.Outline
|
outline *model.Outline
|
||||||
|
|
||||||
|
// External outlines.
|
||||||
|
externalOutline *model.PdfOutlineTreeNode
|
||||||
|
|
||||||
// Forms.
|
// Forms.
|
||||||
acroForm *model.PdfAcroForm
|
acroForm *model.PdfAcroForm
|
||||||
|
|
||||||
@ -70,6 +73,13 @@ func (c *Creator) SetForms(form *model.PdfAcroForm) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetOutlineTree adds the specified outline tree to the PDF file generated
|
||||||
|
// by the creator. Adding an external outline tree disables the automatic
|
||||||
|
// generation of outlines done by the creator for the relevant components.
|
||||||
|
func (c *Creator) SetOutlineTree(outlineTree *model.PdfOutlineTreeNode) {
|
||||||
|
c.externalOutline = outlineTree
|
||||||
|
}
|
||||||
|
|
||||||
// FrontpageFunctionArgs holds the input arguments to a front page drawing function.
|
// FrontpageFunctionArgs holds the input arguments to a front page drawing function.
|
||||||
// It is designed as a struct, so additional parameters can be added in the future with backwards
|
// It is designed as a struct, so additional parameters can be added in the future with backwards
|
||||||
// compatibility.
|
// compatibility.
|
||||||
@ -588,7 +598,9 @@ func (c *Creator) Write(ws io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Outlines.
|
// Outlines.
|
||||||
if c.outline != nil && c.AddOutlines {
|
if c.externalOutline != nil {
|
||||||
|
pdfWriter.AddOutlineTree(c.externalOutline)
|
||||||
|
} else if c.outline != nil && c.AddOutlines {
|
||||||
pdfWriter.AddOutlineTree(&c.outline.ToPdfOutline().PdfOutlineTreeNode)
|
pdfWriter.AddOutlineTree(&c.outline.ToPdfOutline().PdfOutlineTreeNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user