Help us shape the future of Go! Take the 2026 Go Developer Survey

navigation

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package navigation 将 OFD 链接动作、跳转目标、书签和大纲转换为输出契约。

本包只读取模型并通过 PageResolver 将页面 ID 映射为输出页序,不持有解析文档、 页面租约或绘制状态。主渲染包负责页面遍历与复合对象热区的坐标和裁剪映射。 没有目标页映射时仅保留 URI,目标不在输出中时丢弃相应的内部跳转。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionLink(actions models.Actions, resolve PageResolver) (drawing.PageLink, bool)

ActionLink 按动作顺序返回首个可解析的 CLICK 链接,同一动作中 URI 优先于 内部跳转。目标页无法解析时跳过该动作,继续检查后续动作。

func AnnotationLinks(annot *models.PageAnnot, resolve PageResolver) []drawing.PageLink

AnnotationLinks 按 Appearance 自身的页面边界收集批注链接。

func BoundaryUsable

func BoundaryUsable(boundary models.StBox) bool

BoundaryUsable 判断热区能否成为点击区域。

真实文档里存在负宽高(internal/models 的 Boundary 注释对此有说明),负宽高 同样表示一个矩形,需在归一化时取绝对值;但宽高为零、非有限值则没有可点区域。

func GraphicUnit

func GraphicUnit(item models.PageItem) *models.CTGraphicUnit

GraphicUnit 返回图元携带的只读图形单元(含 Actions 与 Boundary)。

func Links(items []models.PageItem, resolve PageResolver) []drawing.PageLink

Links 收集对象块内的链接,使用图元自身的局部 Boundary,不展开复合资源。 页面级提取方通过 content 遍历取得映射,再调用 ActionLink 解析动作。

func Outlines

func Outlines(source *models.OutlineList, bookmarkList *models.BookmarkList, resolve PageResolver) []drawing.PageOutline

Outlines 返回文档大纲的扁平条目序列,按文档顺序排列。

resolve 与 ActionLink 共用页面映射:目标页必须在输出里才能建立跳转。 源树最多访问 64 层,超出部分跳过,不影响后续兄弟节点。

Types

type PageRef

type PageRef struct {
	// Index 是目标页在输出中的页序号(从 0 起)。
	Index int
	// Height 是目标页高度(mm)。
	Height float64
}

PageRef 是内部跳转目标在输出文档中的页序与页面高度。

type PageResolver

type PageResolver func(pageID models.StID) (PageRef, bool)

PageResolver 把 OFD 页面的 StID 解析为目标页在输出中的位置。ok 为 false 表示目标页不会出现在输出里(例如被页码范围裁掉),此时对应链接必须丢弃。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL