navigation

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

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

func ActionLinkWithBookmarks added in v0.2.0

func ActionLinkWithBookmarks(actions spec.Actions, resolve PageResolver, bookmarks map[string]spec.Dest) (drawing.PageLink, bool)

ActionLinkWithBookmarks 按 §14.2 表53解析当前文档作用域中的书签引用。 不修改源动作;书签缺失或目标不可解析时继续检查后续 CLICK 动作。

func ActionRegion added in v0.1.9

func ActionRegion(action spec.Action, unit spec.CTGraphicUnit) *geom.Path

ActionRegion 返回页面坐标的启动区域;Region 位于图元局部空间,先 CTM 再加 Boundary。

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

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

func AnnotationLinksWithBookmarks added in v0.2.0

func AnnotationLinksWithBookmarks(annot *spec.PageAnnot, resolve PageResolver, bookmarks map[string]spec.Dest) []drawing.PageLink

AnnotationLinksWithBookmarks 为批注链接解析所属文档中的书签引用。

func BoundaryUsable

func BoundaryUsable(boundary spec.StBox) bool

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

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

func GraphicUnit

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

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

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

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

func NormalizedRegion added in v0.1.9

func NormalizedRegion(path *geom.Path) string

NormalizedRegion 将启动路径换算为热区外接矩形内的 SVG 路径,供浏览器精确命中。

func Outlines

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

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

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

func Region added in v0.1.9

func Region(region *spec.Region) *geom.Path

Region 按 §14.1 表51、§9.3将启动区域转换为所在坐标系的路径。 缺省返回 nil(使用对象边界),显式空区域返回空路径,不能扩大为整个对象。

func URI added in v0.1.9

func URI(action *spec.ActionURI) string

URI 按 GB/T 33190—2016 §14.4 表56及 RFC 3986 解析 Base 与相对地址。 不可解析的地址不猜测修复;仍由调用方决定允许的协议和打开策略。

Types

type PageRef

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

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

type PageResolver

type PageResolver func(pageID spec.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