models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 11 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 models 提供复用pkg/spec标准声明的内部包装及快速解析入口。 标准声明与标准库 XML 解码直接复用pkg/spec,不再维护标准类型别名。 快速解析、页面尺寸兜底及文字位置兼容策略仍留在内部。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsurePhysicalBox added in v0.1.9

func EnsurePhysicalBox(p *spec.PageArea)

EnsurePhysicalBox 保留页面物理区域的兼容兜底,无效尺寸使用 A4。 这是读取/显示策略,不属于 pkg/spec 的标准声明解码。

func ExpandCGTransformPositions added in v0.1.5

func ExpandCGTransformPositions(codes []spec.TextCode, transforms []spec.CTCGTransform) []spec.CTCGTransform

ExpandCGTransformPositions 将按 TextCode 局部计数的 CGTransform.CodePosition 展开为整个文字对象内的字符位置。规范形式的全局递增位置保持原样;遇到位置重置 时,将后续位置解释为下一段 TextCode 内的偏移,兼容常见的逐字 TextCode 文档。

func ParseDocumentXML added in v0.1.4

func ParseDocumentXML(data []byte) (*spec.Document, error)

ParseDocumentXML 解析 OFD 文档主体 XML。页面列表(Pages/Page)是打开文档时 解析量最大的部分——大文档动辄上千个仅含 ID/BaseLoc 的 Page 元素,用 encoding/xml 反射逐元素 unmarshal 会产生大量分配;这里直接用 tdewolff 的 零分配 XML lexer 重建。其余低频且复杂的子树(CommonData、Outlines、颜色、 权限等)用 fastxml.SpanElement 捕获字节区间后回退 encoding/xml,语义与 xml.Unmarshal 一致。

func ParseResXML added in v0.1.9

func ParseResXML(data []byte) (*spec.Res, error)

ParseResXML 使用 fastxml.Lexer 解析资源文件。低频且结构复杂的资源子树仍由 fastxml.DecodeSpan 按模型解码,颜色空间和调色板则直接从词法 token 重建。

Types

type PageContent

type PageContent spec.PageContent

PageContent 复用标准声明,并保留内部页面尺寸兼容策略。

func ParsePageContentXML added in v0.1.3

func ParsePageContentXML(data []byte) (*PageContent, error)

ParsePageContentXML 解析 OFD 页面内容 XML,入口语义与 xml.Unmarshal 一致: 第一个元素作为根元素跳过,子元素按名称匹配。

func (*PageContent) EnsurePhysicalBox added in v0.0.6

func (p *PageContent) EnsurePhysicalBox()

EnsurePhysicalBox 确保页面区域存在且物理区域有效;这不是标准声明解码行为。

type Signature

type Signature struct {
	spec.Signature

	Type     string `xml:"-"`
	Relative string `xml:"-"`
	FilePath string `xml:"-"`
}

Signature 将标准签名描述与内部加载上下文分开;上下文不参与 XML 解码。

Jump to

Keyboard shortcuts

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