mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-02 22:17:06 +08:00
Add GetContext method for exporting the outline tree node context
This commit is contained in:
parent
3e66280dbf
commit
2c395a6598
@ -185,8 +185,10 @@ func (r *PdfReader) newPdfOutlineItemFromIndirectObject(container *core.PdfIndir
|
|||||||
return item, nil
|
return item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the outer object of the tree node (Outline or OutlineItem).
|
// GetContext returns the context of the outline tree node, which is either a
|
||||||
func (n *PdfOutlineTreeNode) getOuter() PdfModel {
|
// *PdfOutline or a *PdfOutlineItem. The method returns null for uninitialized
|
||||||
|
// tree nodes.
|
||||||
|
func (n *PdfOutlineTreeNode) GetContext() PdfModel {
|
||||||
if outline, isOutline := n.context.(*PdfOutline); isOutline {
|
if outline, isOutline := n.context.(*PdfOutline); isOutline {
|
||||||
return outline
|
return outline
|
||||||
}
|
}
|
||||||
@ -200,12 +202,12 @@ func (n *PdfOutlineTreeNode) getOuter() PdfModel {
|
|||||||
|
|
||||||
// GetContainingPdfObject returns the container of the outline tree node (indirect object).
|
// GetContainingPdfObject returns the container of the outline tree node (indirect object).
|
||||||
func (n *PdfOutlineTreeNode) GetContainingPdfObject() core.PdfObject {
|
func (n *PdfOutlineTreeNode) GetContainingPdfObject() core.PdfObject {
|
||||||
return n.getOuter().GetContainingPdfObject()
|
return n.GetContext().GetContainingPdfObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToPdfObject returns the PDF representation of the outline tree node.
|
// ToPdfObject returns the PDF representation of the outline tree node.
|
||||||
func (n *PdfOutlineTreeNode) ToPdfObject() core.PdfObject {
|
func (n *PdfOutlineTreeNode) ToPdfObject() core.PdfObject {
|
||||||
return n.getOuter().ToPdfObject()
|
return n.GetContext().ToPdfObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetContainingPdfObject returns the container of the outline (indirect object).
|
// GetContainingPdfObject returns the container of the outline (indirect object).
|
||||||
@ -225,12 +227,11 @@ func (o *PdfOutline) ToPdfObject() core.PdfObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if o.Last != nil {
|
if o.Last != nil {
|
||||||
dict.Set("Last", o.Last.getOuter().GetContainingPdfObject())
|
dict.Set("Last", o.Last.GetContext().GetContainingPdfObject())
|
||||||
//PdfObjectConverterCache[o.Last.getOuter()]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.Parent != nil {
|
if o.Parent != nil {
|
||||||
dict.Set("Parent", o.Parent.getOuter().GetContainingPdfObject())
|
dict.Set("Parent", o.Parent.GetContext().GetContainingPdfObject())
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.Count != nil {
|
if o.Count != nil {
|
||||||
@ -284,16 +285,13 @@ func (oi *PdfOutlineItem) ToPdfObject() core.PdfObject {
|
|||||||
dict.Set("First", oi.First.ToPdfObject())
|
dict.Set("First", oi.First.ToPdfObject())
|
||||||
}
|
}
|
||||||
if oi.Prev != nil {
|
if oi.Prev != nil {
|
||||||
dict.Set("Prev", oi.Prev.getOuter().GetContainingPdfObject())
|
dict.Set("Prev", oi.Prev.GetContext().GetContainingPdfObject())
|
||||||
//PdfObjectConverterCache[oi.Prev.getOuter()]
|
|
||||||
}
|
}
|
||||||
if oi.Last != nil {
|
if oi.Last != nil {
|
||||||
dict.Set("Last", oi.Last.getOuter().GetContainingPdfObject())
|
dict.Set("Last", oi.Last.GetContext().GetContainingPdfObject())
|
||||||
// PdfObjectConverterCache[oi.Last.getOuter()]
|
|
||||||
}
|
}
|
||||||
if oi.Parent != nil {
|
if oi.Parent != nil {
|
||||||
dict.Set("Parent", oi.Parent.getOuter().GetContainingPdfObject())
|
dict.Set("Parent", oi.Parent.GetContext().GetContainingPdfObject())
|
||||||
//PdfObjectConverterCache[oi.Parent.getOuter()]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return container
|
return container
|
||||||
|
Loading…
x
Reference in New Issue
Block a user