mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-26 13:48:55 +08:00
Improve traversal of outline item nodes in the GetOutlinesFlattened method
This commit is contained in:
parent
4b1d8a98fd
commit
ac736a2f78
@ -414,13 +414,11 @@ func (r *PdfReader) GetOutlinesFlattened() ([]*PdfOutlineTreeNode, []string, err
|
||||
return
|
||||
}
|
||||
|
||||
if item, isItem := node.context.(*PdfOutlineItem); isItem {
|
||||
item, isItem := node.context.(*PdfOutlineItem)
|
||||
if isItem {
|
||||
*outlineList = append(*outlineList, &item.PdfOutlineTreeNode)
|
||||
title := strings.Repeat(" ", depth*2) + item.Title.Str()
|
||||
title := strings.Repeat(" ", depth*2) + item.Title.Decoded()
|
||||
*titleList = append(*titleList, title)
|
||||
if item.Next != nil {
|
||||
flattenFunc(item.Next, outlineList, titleList, depth)
|
||||
}
|
||||
}
|
||||
|
||||
if node.First != nil {
|
||||
@ -428,6 +426,10 @@ func (r *PdfReader) GetOutlinesFlattened() ([]*PdfOutlineTreeNode, []string, err
|
||||
*titleList = append(*titleList, title)
|
||||
flattenFunc(node.First, outlineList, titleList, depth+1)
|
||||
}
|
||||
|
||||
if isItem && item.Next != nil {
|
||||
flattenFunc(item.Next, outlineList, titleList, depth)
|
||||
}
|
||||
}
|
||||
flattenFunc(r.outlineTree, &outlineNodeList, &flattenedTitleList, 0)
|
||||
return outlineNodeList, flattenedTitleList, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user