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

pdfgo

package module
v0.0.0-...-4d52abc Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 56 Imported by: 1

README

PDFGo PkgGoDev

原生、全平台、纯 Go 语言高性能 PDF 处理引擎

安装指南

go get -u github.com/xiaoqidun/pdfgo

应用案例

OFDGo:使用 PDFGo 将 PDF 转换为可编辑的 OFD

授权协议

本项目使用 Apache License 2.0 授权协议

Documentation

Overview

Package pdfgo 原生、全平台、纯 Go 语言高性能 PDF 处理引擎

Index

Constants

This section is empty.

Variables

View Source
var ErrDestinationNotFound = errors.New("destination not found")

ErrDestinationNotFound 表示命名目标在文档目标表中不存在

View Source
var ErrInvalidAction = errors.New("invalid action")

ErrInvalidAction 表示已识别的动作结构或参数错误,不包含资源读取和取消错误

View Source
var ErrInvalidAnnotationAppearance = errors.New("invalid annotation appearance stream")

ErrInvalidAnnotationAppearance 表示所选注解外观结构无效,不包含读取和取消错误

View Source
var ErrInvalidDestination = errors.New("invalid destination")

ErrInvalidDestination 表示目标结构或参数不符合标准,不包含读取和取消错误

View Source
var ErrPassword = errors.New("PDF password required or incorrect")

ErrPassword 表示需要提供正确的PDF用户或所有者密码

Functions

func DecodeTextString

func DecodeTextString(value String) (string, error)

DecodeTextString 按PDF标准表D.2及Unicode文本串编码读取文字 入参: value PDF字符串 返回: string Unicode文字, error 无效编码

func EncodeImageResource

func EncodeImageResource(ctx context.Context, source image.Image, options CompressionOptions) ([]byte, error)

EncodeImageResource 编码并优化资源图片,有损模式允许不透明照片采用JPEG,其余保留PNG 不修改输入,不降采样,不附加密度或色彩配置;调用方须按返回数据设置格式声明 编码候选超过64MiB时返回io.ErrShortBuffer,失败时不返回编码数据 入参: ctx 取消上下文, source 已解码图像, options 压缩配置 返回: []byte 图片编码, error 参数、编码或取消错误

func EncodePNG

func EncodePNG(ctx context.Context, writer io.Writer, source image.Image) error

EncodePNG 按行无损编码图像,保留颜色精度及透明度,不展开整幅延迟图像 图像解码由调用方完成,取消或写入失败时输出可能不完整 入参: ctx 取消上下文, writer 输出流, source 已解码图像 返回: error 图像参数、取消或写入错误

func EncodePNGWithOptions

func EncodePNGWithOptions(ctx context.Context, writer io.Writer, source image.Image, options CompressionOptions) error

EncodePNGWithOptions 编码并优化固定PNG格式,共用已解码像素,不修改输入 不降采样,不附加密度或色彩配置;失败时输出可能不完整 编码候选超过64MiB时返回io.ErrShortBuffer 入参: ctx 取消上下文, writer 输出流, source 已解码图像, options 压缩配置 返回: error 参数、编码、取消或写入错误

func OptimizeImage

func OptimizeImage(ctx context.Context, data []byte, options CompressionOptions) ([]byte, error)

OptimizeImage 优化PNG或JPEG编码,只采用更小的结果,不改变尺寸和透明度 无损保留像素与元数据,有损可降低RGB精度或JPEG质量;未知格式原样返回 返回值可能引用输入数据;不修改输入,调用方应将结果视为只读 入参: ctx 取消上下文, data 图片数据, options 压缩配置 返回: []byte 图片数据, error 编码错误

func OptimizeImageResource

func OptimizeImageResource(ctx context.Context, data []byte, options CompressionOptions, size image.Point) ([]byte, error)

OptimizeImageResource 优化资源图片,有损模式允许无元数据的不透明照片改用JPEG 调用方须按返回数据更新格式声明;固定格式导出应使用OptimizeImageSize 不修改输入;返回值可能引用输入,调用方应视为只读 入参: ctx 取消上下文, data 图片数据, options 压缩配置, size 像素需求 返回: []byte 更小的图片数据, error 编码错误

func OptimizeImageSize

func OptimizeImageSize(ctx context.Context, data []byte, options CompressionOptions, size image.Point) ([]byte, error)

OptimizeImageSize 优化图片编码,有损模式按两轴像素需求等比缩小,只采用更小的结果 未知显示尺寸时传零值,不降采样;不会放大图片或修改输入数据 入参: ctx 取消上下文, data 图片数据, options 压缩配置, size 像素需求 返回: []byte 图片数据, error 编码错误

func OptimizeJPEG

func OptimizeJPEG(ctx context.Context, data []byte) ([]byte, error)

OptimizeJPEG 在不改变量化系数、尺寸和元数据的情况下优化JPEG熵编码 当前优化单扫描顺序霍夫曼JPEG,其他编码及没有体积收益的图片返回原数据 返回数据可能与输入共享内存,调用方不得修改;取消与损坏扫描返回错误 入参: ctx 取消上下文, data JPEG原始数据 返回: []byte 优化数据, error 编码错误

func ParseDate

func ParseDate(value string) (time.Time, error)

ParseDate 解析PDF日期,省略字段使用标准默认值,接受Adobe规范的结尾时区引号 入参: value 已解码的PDF日期字符串 返回: time.Time 保留当地时间和时区的日期, error 日期语法或取值错误

func ResizeImage

func ResizeImage(ctx context.Context, src image.Image, size image.Point) (image.Image, error)

ResizeImage 按两轴像素需求等比缩小图片,保留灰度和透明通道,不修改输入 需求非正或无需缩小时返回原图;超出工作内存预算时保持原尺寸 入参: ctx 取消上下文, src 原图, size 像素需求 返回: image.Image 输出图片, error 取消错误

func ThreeDArtworkChecksum

func ThreeDArtworkChecksum(ctx context.Context, stream *Stream) ([16]byte, error)

ThreeDArtworkChecksum 计算三维模型数据的MD5,不将PDF流过滤器编码计入模型内容 校验仅用于检测模型变化,不用于安全认证 入参: ctx 取消上下文, stream 三维模型流 返回: [16]byte 校验和, error 解码或取消错误

func WalkOperations

func WalkOperations(ctx context.Context, data []byte, visit func(Operation) error) error

WalkOperations 顺序解析内容操作,未知操作符交由调用方处理 入参: ctx 取消上下文, data 内容流, visit 操作访问函数 返回: error 错误信息

Types

type ActionInfo

type ActionInfo struct {
	Type       Name
	Dictionary Dictionary
}

ActionInfo 保存动作类型和原始属性,不执行脚本、启动程序或访问网络

type ActionTarget

type ActionTarget struct {
	Reference Reference
	Name      string
}

ActionTarget 保存注解或字段的间接引用或完整字段名称,两者仅有一个有效

type ActionTrigger

type ActionTrigger struct {
	Event  Name
	Action Dictionary
}

ActionTrigger 保存附加动作的事件和只读字典,不执行动作或展开Next链

type Annotation

type Annotation struct {
	Reference  Reference
	Subtype    Name
	Rect       Rectangle
	Dictionary Dictionary
}

Annotation 保存注解类型、区域及原始字典,不执行动作

func (Annotation) IsStandard

func (a Annotation) IsStandard() bool

IsStandard 判断注解类型是否由PDF标准定义,不表示交互能力已实现 返回: bool 标准类型

type AnnotationLocation

type AnnotationLocation struct {
	Page  Reference
	Index int
}

AnnotationLocation 通过页面引用和从零开始的注解索引定位页面注解

type Array

type Array []Object

Array 按原始顺序保存数组元素

type AttachmentAction

type AttachmentAction struct {
	Key       string
	NewWindow *bool
}

AttachmentAction 按名称树原始键打开输出文档中的附件,不执行文件 NewWindow为空时沿用阅读器偏好,PDF标准仅对PDF附件定义窗口行为

type AxialGradient

type AxialGradient struct {
	Start, End Point
	Matrix     Matrix
	Extend     [2]bool
	Stops      []GradientStop
	Space      *ColorSpace
	Intent     Name
	Background *[4]float64
	Bounds     *Rectangle
	// contains filtered or unexported fields
}

AxialGradient 保存页面坐标中的渐变轴及两端延伸方式 Stops仅在函数可精确展开为线性分段时提供,否则通过ValuesAt或ColorAt求值 Background及Bounds仅用于着色图案,Matrix将Bounds映射到页面

func (*AxialGradient) ColorAt

func (g *AxialGradient) ColorAt(position float64) ([3]float64, error)

ColorAt 在源颜色空间内插值,再按渲染意图转换为sRGB 入参: position 归一化轴位置,范围外使用端点颜色 返回: [3]float64 sRGB颜色, error 无效渐变或颜色变换错误

func (*AxialGradient) ColorantAt

func (g *AxialGradient) ColorantAt(position float64) (*ColorantPaint, error)

ColorantAt 求值轴向渐变的源色料浓度,不使用备用色标反推浓度 入参: position 归一化轴位置,范围外使用端点 返回: *ColorantPaint 色料快照,非色料渐变为nil, error 参数或函数错误

func (*AxialGradient) ColorantSpace

func (g *AxialGradient) ColorantSpace() *ColorantSpace

ColorantSpace 返回轴向渐变的只读原始色料定义 返回: *ColorantSpace 色料定义,普通颜色空间为nil

func (*AxialGradient) ColorantValuesAt

func (g *AxialGradient) ColorantValuesAt(position float64, out []float64) error

ColorantValuesAt 将轴向渐变的原始浓度写入调用方缓冲 入参: position 归一化轴位置, out 与色料数等长的输出缓冲 返回: error 非色料渐变、参数或函数错误,错误时不保证缓冲内容

func (*AxialGradient) PreparePosition

func (g *AxialGradient) PreparePosition() (GradientPosition, error)

PreparePosition 准备轴向参数求值,不近似颜色函数或应用BBox 返回: GradientPosition 只读几何, error 非有限坐标

func (*AxialGradient) ValuesAt

func (g *AxialGradient) ValuesAt(position float64) ([4]float64, error)

ValuesAt 按原始函数计算轴向渐变的源颜色分量 入参: position 归一化轴位置,范围外使用端点 返回: [4]float64 源空间分量, error 无效求值

type Boolean

type Boolean bool

Boolean 表示布尔对象

type CIDMap

type CIDMap map[string]uint16

CIDMap 保存字符码到CID的映射

func ParseCIDMap

func ParseCIDMap(data []byte) (CIDMap, error)

ParseCIDMap 读取CMap中的字符码到CID的直接映射及连续范围 入参: data CMap数据 返回: CIDMap 字符映射, error 错误信息

func ParseCIDMapContext

func ParseCIDMapContext(ctx context.Context, data []byte) (CIDMap, error)

ParseCIDMapContext 读取并展开CID映射,继承及范围展开可取消 入参: ctx 取消上下文, data CMap数据 返回: CIDMap 完整字符映射, error 解析或取消错误

type ChoiceField

type ChoiceField struct {
	Options     []ChoiceOption
	Values      []string
	Selected    []int
	TopIndex    int
	Combo       bool
	Editable    bool
	MultiSelect bool
}

ChoiceField 保存选择字段当前状态,Options保持文档顺序,Selected为零基索引

type ChoiceOption

type ChoiceOption struct {
	Value string
	Label string
}

ChoiceOption 保存选择字段的导出值和显示文字

type ColorConversion

type ColorConversion struct {
	BlackGeneration   *ColorFunction
	UndercolorRemoval *ColorFunction
}

ColorConversion 保存RGB转设备四色的黑版生成及底色去除函数,空值采用恒等设备默认值

func (ColorConversion) RGBToCMYK

func (c ColorConversion) RGBToCMYK(rgb [3]float64) ([4]float64, error)

RGBToCMYK 按PDF设备转换规则生成黑版并去除底色,最终分量裁切至单位范围 入参: rgb 设备RGB单位分量 返回: [4]float64 设备四色分量, error 无效分量或函数错误

type ColorConverter

type ColorConverter struct {
	// contains filtered or unexported fields
}

ColorConverter 保存颜色空间及转换参数的只读快照,可用于并发分量转换

func (*ColorConverter) Convert

func (c *ColorConverter) Convert(values []float64) ([4]float64, error)

Convert 验证源分量并使用已准备的空间转换,不保留输入或共享求值缓冲 入参: values 源颜色分量 返回: [4]float64 目标分量, error 分量或变换错误

type ColorFunction

type ColorFunction struct {
	// contains filtered or unexported fields
}

ColorFunction 保存单输入单输出颜色函数,解析后可独立于阅读器并发求值

func (*ColorFunction) Evaluate

func (f *ColorFunction) Evaluate(value float64) (float64, error)

Evaluate 按函数定义域及输出范围求值,空函数为恒等函数 入参: value 有限输入值 返回: float64 函数结果, error 非有限值或计算错误

type ColorSpace

type ColorSpace struct {
	Model Name
	// contains filtered or unexported fields
}

ColorSpace 保存设备或校准颜色空间,区分源分量、空间转换与sRGB显示 Model为DeviceGray、DeviceRGB或DeviceCMYK,校准色保留对应模型与颜色变换

func NewCalRGBColorSpace

func NewCalRGBColorSpace(white, black, gamma [3]float64, matrix [9]float64) (*ColorSpace, error)

NewCalRGBColorSpace 以校准参数建立独立源空间,不生成或声明ICC配置 入参: white XYZ白点且Y为1, black XYZ黑点, gamma 各通道解码指数, matrix 按列排列的RGB到XYZ矩阵 返回: *ColorSpace 校准空间, error 参数错误

func NewICCColorSpace

func NewICCColorSpace(data []byte) (*ColorSpace, error)

NewICCColorSpace 解析独立ICC配置快照,复用PDF颜色变换,不依赖PDF阅读器 转换输入为单位分量,Lab映射到L[0,100]及a、b[-128,127] 入参: data 配置文件,支持灰度、RGB、CMYK及Lab源空间 返回: *ColorSpace 不保留调用方缓冲的颜色空间, error 配置或变换错误

func (*ColorSpace) Blend

func (s *ColorSpace) Blend(backdrop, source []float64, mode Name) ([4]float64, error)

Blend 按PDF标准混合同空间单位分量,四色在加色补色中计算,不执行空间转换 入参: backdrop 背景分量, source 源分量, mode 标准混合模式 返回: [4]float64 混合分量, error 空间、分量或模式错误

func (*ColorSpace) Calibrated

func (s *ColorSpace) Calibrated() bool

Calibrated 判断颜色空间是否含校准参数 返回: bool 是否校准

func (*ColorSpace) Components

func (s *ColorSpace) Components() int

Components 返回颜色空间的分量数 返回: int 分量数

func (*ColorSpace) Composite

func (s *ColorSpace) Composite(backdrop, source []float64, backdropAlpha, sourceAlpha float64, mode Name) ([4]float64, float64, error)

Composite 按PDF基本透明公式合成非预乘分量,透明颜色不参与求值,不处理组挖空或套印 入参: backdrop 背景分量, source 源分量, backdropAlpha 背景透明度, sourceAlpha 源透明度, mode 标准混合模式 返回: [4]float64 结果分量, float64 结果透明度, error 空间、分量、透明度或模式错误

func (*ColorSpace) CompositeOverprint

func (s *ColorSpace) CompositeOverprint(backdrop, source []float64, backdropAlpha, sourceAlpha float64, mode Name, marked []bool) ([4]float64, float64, error)

CompositeOverprint 按兼容套印的隐式组规则合成基本对象,通道选择由源空间和套印模式决定 入参: backdrop 背景分量, source 源分量, backdropAlpha 背景透明度, sourceAlpha 源透明度, mode 当前混合模式, marked 已按套印规则选定的通道 返回: [4]float64 结果分量, float64 结果透明度, error 空间、分量、透明度、模式或通道错误

func (*ColorSpace) Convert

func (s *ColorSpace) Convert(values []float64, source *ColorSpace, intent Name) ([4]float64, error)

Convert 将源空间分量转换到当前颜色空间,相同校准空间保留原值 DeviceRGB转DeviceCMYK采用恒等黑版生成及底色去除函数 入参: values 源分量, source 源空间, intent 渲染意图 返回: [4]float64 目标分量, error 无效分量或未支持的目标变换

func (*ColorSpace) ConvertWith

func (s *ColorSpace) ConvertWith(values []float64, source *ColorSpace, intent Name, conversion ColorConversion) ([4]float64, error)

ConvertWith 在设备RGB转设备四色时应用指定函数,不改变灰度、校准色及同空间转换 入参: values 源分量, source 源空间, intent 渲染意图, conversion 设备转换函数 返回: [4]float64 目标分量, error 无效分量或变换错误

func (*ColorSpace) DefaultIntent

func (s *ColorSpace) DefaultIntent() Name

DefaultIntent 返回ICC头建议的渲染意图,不替代PDF内容流指定的意图 返回: Name 配置默认意图,设备及其他校准空间为相对色度

func (*ColorSpace) Device

func (s *ColorSpace) Device() bool

Device 判断分量是否属于原始设备空间,不将校准色的RGB显示结果视为设备源色 返回: bool 是否原始设备空间

func (*ColorSpace) Equal

func (s *ColorSpace) Equal(other *ColorSpace) bool

Equal 判断颜色模型、配置定义与分量范围是否相同,不受逆向缓存初始化影响 入参: other 待比较空间 返回: bool 是否相同

func (*ColorSpace) ICCProfile

func (s *ColorSpace) ICCProfile(intent Name) []byte

ICCProfile 导出独立配置快照,按ICC嵌入规则设置意图,不改标签与配置标识 入参: intent 输出渲染意图,空值或未知值按PDF规则使用相对色度 返回: []byte 配置快照,非ICC空间为nil

func (*ColorSpace) ICCSource

func (s *ColorSpace) ICCSource() (Name, [8]float64)

ICCSource 返回ICC源模型及实际分量范围,不分配配置副本 返回: Name GRAY、RGB、CMYK或Lab,非ICC空间为空, [8]float64 各分量的上下限

func (*ColorSpace) Luminosity

func (s *ColorSpace) Luminosity(values []float64, intent Name) (float64, error)

Luminosity 按PDF蒙版规则计算亮度,ICC使用连接空间的Y分量 入参: values 已合成的颜色分量, intent 渲染意图 返回: float64 单位亮度, error 分量或变换错误

func (*ColorSpace) PrepareConversion

func (s *ColorSpace) PrepareConversion(source *ColorSpace, intent Name, conversion ColorConversion) (ColorConverter, error)

PrepareConversion 准备源空间到当前空间的转换,不近似配置文件或颜色函数 入参: source 源空间, intent 渲染意图, conversion 设备转换函数 返回: ColorConverter 只读转换器, error 无效空间

func (*ColorSpace) SRGB

func (s *ColorSpace) SRGB(values []float64, intent Name) ([3]float64, error)

SRGB 将颜色空间分量转换为sRGB显示颜色 入参: values 单位分量, intent 渲染意图 返回: [3]float64 sRGB颜色, error 分量或变换错误

func (*ColorSpace) SRGBEquivalent

func (s *ColorSpace) SRGBEquivalent() bool

SRGBEquivalent 检查混合空间与sRGB的偏差是否在8位量化精度内 返回: bool 是否等价

type ColorantDevice

type ColorantDevice struct {
	Space *ColorSpace
	Spots []Name
	// contains filtered or unexported fields
}

ColorantDevice 保存输出设备的原生过程空间与额外色料,公开字段只读 原生过程空间仅接受设备色,额外色料仅用于减色设备,不代表屏幕备用颜色

func NewColorantDevice

func NewColorantDevice(space *ColorSpace, spots []Name) (*ColorantDevice, error)

NewColorantDevice 建立只读输出设备定义,复制色料列表并拒绝保留名称和重复色料 入参: space 原生设备空间,nil使用设备RGB, spots 额外减色色料 返回: *ColorantDevice 输出设备, error 设备或色料错误

func (*ColorantDevice) Composite

func (d *ColorantDevice) Composite(out, backdrop []float64, source ColorantResult, backdropAlpha, sourceAlpha float64, mode Name) (float64, error)

Composite 按PDF透明模型分别合成过程色和原生专色,未指定通道按无色料计算,不执行套印 入参: out 输出缓冲,可与backdrop相同, backdrop 非预乘过程色及专色背景, source 原生源色料, backdropAlpha 背景透明度, sourceAlpha 源透明度, mode 标准混合模式 返回: float64 结果透明度, error 定义错误或仍需合成备用色,错误时不修改输出

func (*ColorantDevice) CompositeOpaque

func (d *ColorantDevice) CompositeOpaque(out, backdrop []float64, source ColorantResult, overprint bool) error

CompositeOpaque 按不透明分色套印规则合成原生通道,显式零值仍标记命名通道 入参: out 输出缓冲,可与backdrop相同, backdrop 过程色及专色背景, source 已求值的原生色料, overprint 是否保留未标记通道 返回: error 分量错误或仍需合成备用色,错误时不修改输出

func (*ColorantDevice) CompositeOverprint

func (d *ColorantDevice) CompositeOverprint(out, backdrop []float64, source ColorantResult, backdropAlpha, sourceAlpha float64, mode Name) (float64, error)

CompositeOverprint 按兼容套印和当前混合模式合成原生色料,源掩码须已按套印模式选择 入参: out 输出缓冲,可与backdrop相同, backdrop 非预乘背景, source 原生源色料, backdropAlpha 背景透明度, sourceAlpha 源透明度, mode 当前混合模式 返回: float64 结果透明度, error 定义错误或仍需合成备用色,错误时不修改输出

type ColorantGroup

type ColorantGroup struct {
	Space  *ColorSpace
	Device *ColorantDevice
}

ColorantGroup 保存只读组混合空间和输出设备,过程色转换不改变原生专色身份

func NewColorantGroup

func NewColorantGroup(space *ColorSpace, device *ColorantDevice) (*ColorantGroup, error)

NewColorantGroup 建立组混合定义,不将设备专色转换为组过程色 入参: space 组空间,nil继承设备或使用设备RGB, device 输出设备,nil仅处理过程色 返回: *ColorantGroup 组定义, error 空间或设备错误

func (*ColorantGroup) Components

func (g *ColorantGroup) Components() int

Components 返回组过程色及设备专色的总分量数 返回: int 分量数,无效定义为零

func (*ColorantGroup) Composite

func (g *ColorantGroup) Composite(out, backdrop []float64, source ColorantResult, backdropAlpha, sourceAlpha float64, mode Name) (float64, error)

Composite 在组空间合成过程色和独立专色,未指定通道按无色料计算 入参: out 输出缓冲,可与backdrop相同, backdrop 非预乘背景, source 已在组空间求值的色料, backdropAlpha 背景透明度, sourceAlpha 源透明度, mode 混合模式 返回: float64 结果透明度, error 定义或数值错误,错误时不修改输出

func (*ColorantGroup) CompositeGroup

func (g *ColorantGroup) CompositeGroup(target *ColorantPixel, initial, result ColorantPixel, source *ColorantGroup, opacity float64, mode, intent Name, conversion ColorConversion) error

CompositeGroup 移除组初始背景后合成到父组,专色只参与混合而不参与空间转换 入参: target 父组累计结果, initial 源组初始背景, result 源组累计结果, source 源组定义, opacity 组不透明度及蒙版乘积, mode 混合模式, intent 渲染意图, conversion 设备转换函数 返回: error 定义或数值错误,错误时不修改输出;非隔离组须继承父空间

func (*ColorantGroup) CompositeOverprint

func (g *ColorantGroup) CompositeOverprint(out, backdrop []float64, source ColorantResult, backdropAlpha, sourceAlpha float64, mode Name) (float64, error)

CompositeOverprint 在组空间应用基本对象兼容套印,不将此规则用于整组结果 入参: out 输出缓冲,可与backdrop相同, backdrop 非预乘背景, source 已选择套印通道的色料, backdropAlpha 背景透明度, sourceAlpha 源透明度, mode 混合模式 返回: float64 结果透明度, error 定义或数值错误,错误时不修改输出

func (*ColorantGroup) PrepareGroup

func (g *ColorantGroup) PrepareGroup(source *ColorantGroup, mode, intent Name, conversion ColorConversion) (ColorantGroupCompositor, error)

PrepareGroup 校验跨组混合定义,逐像素复用过程空间和原生专色布局 入参: source 源组定义, mode 混合模式, intent 渲染意图, conversion 设备转换函数 返回: ColorantGroupCompositor 只读合成器, error 空间、模式或设备错误

func (*ColorantGroup) Resolve

func (g *ColorantGroup) Resolve(source *ColorantPaint, intent Name, softMask bool) (ColorantResult, error)

Resolve 在组空间求值源画刷,软蒙版不保留原生专色 入参: source 只读源色料及浓度, intent 渲染意图, softMask 是否用于软蒙版组 返回: ColorantResult 组过程色、原生专色及备用色, error 定义或变换错误

type ColorantGroupCompositor

type ColorantGroupCompositor struct {
	// contains filtered or unexported fields
}

ColorantGroupCompositor 保存只读组合成参数,复用空间校验和通道布局

func (*ColorantGroupCompositor) Composite

func (c *ColorantGroupCompositor) Composite(target *ColorantPixel, initial, result ColorantPixel, opacity float64) error

Composite 将已准备的源组结果合成到父组,错误时不修改当前输出 入参: target 父组结果, initial 源组初始背景, result 源组累计结果, opacity 组不透明度及蒙版乘积 返回: error 分量、透明度或空间转换错误

type ColorantPaint

type ColorantPaint struct {
	Space *ColorantSpace
	Tints []float64
	// contains filtered or unexported fields
}

ColorantPaint 保存只读源浓度快照,普通四分量内嵌保存,避免独立浓度缓冲分配

type ColorantPixel

type ColorantPixel struct {
	Values []float64
	Alpha  float64
	Shape  float64
	Effect float64
}

ColorantPixel 保存非预乘过程色及专色,所有通道共用Alpha、Shape和Effect Effect为不含初始背景的累计透明度,隔离组使用零透明度初值

func (*ColorantPixel) Interpolate

func (p *ColorantPixel) Interpolate(source ColorantPixel, shape float64) error

Interpolate 按形状覆盖混合预乘颜色和累计透明度,形状由调用方独立累计 入参: source 候选结果, shape 覆盖率 返回: error 分量或数值错误,错误时不修改输出

func (*ColorantPixel) Knockout

func (p *ColorantPixel) Knockout(initial, source ColorantPixel) error

Knockout 按对象形状移除之前的贡献,不将透明度当作覆盖率 入参: initial 组初始背景, source 已与初始背景合成的候选结果 返回: error 分量或数值错误,错误时不修改输出

type ColorantProcess

type ColorantProcess struct {
	// contains filtered or unexported fields
}

ColorantProcess 保存完全原生的过程通道映射,不包含备用色或独立专色 创建后可并发复用,不持有调用方浓度缓冲

func (*ColorantProcess) AlternateEquivalent

func (p *ColorantProcess) AlternateEquivalent() bool

AlternateEquivalent 判断是否已证明备用变换与原生过程分量完全等价 返回: bool 同空间且变换等价,未能证明时为false,不代表一定存在色差

func (*ColorantProcess) Convert

func (p *ColorantProcess) Convert(tints []float64) ([4]float64, error)

Convert 将原始浓度写入原生过程分量,不执行备用颜色反推 入参: tints 源浓度,与色料定义等长 返回: [4]float64 过程空间分量, error 分量或非有限值错误

func (*ColorantProcess) Mask

func (p *ColorantProcess) Mask() [4]bool

Mask 返回显式指定的过程通道,零浓度仍视为已指定 返回: [4]bool 过程通道标记

type ColorantResult

type ColorantResult struct {
	Process     *Paint
	ProcessMask [4]bool
	Spots       []float64
	SpotMask    []bool
	Alternates  []Paint
}

ColorantResult 分别保存设备过程色、设备专色与不可用色料的备用画刷 ProcessMask与SpotMask区分未指定通道和显式零值,Spots按输出设备顺序保存 Alternates不预先混合,调用方须按输出设备及透明组规则合成,不将近似RGB当作原生色料

type ColorantSpace

type ColorantSpace struct {
	Names    []Name
	NChannel bool
	Process  *ProcessColorants
	// contains filtered or unexported fields
}

ColorantSpace 保存不可变分色定义,Names与Process切片只读,不持有Reader NChannel保留独立过程空间和专色变换,普通DeviceN使用整体备用变换

func (*ColorantSpace) PrepareProcess

func (s *ColorantSpace) PrepareProcess(device *ColorantDevice, group *ColorSpace, softMask bool) *ColorantProcess

PrepareProcess 编译无需备用变换的过程通道,不能等价映射时返回nil 入参: device 输出设备, group 组混合空间,nil继承设备, softMask 是否用于软蒙版 返回: *ColorantProcess 原生映射,需备用色或独立专色时为nil

func (*ColorantSpace) Resolve

func (s *ColorantSpace) Resolve(tints []float64, device *ColorantDevice, intent Name, softMask bool) (ColorantResult, error)

Resolve 按设备能力选择原生色料或备用画刷,NChannel逐分量处理而DeviceN整体回退 入参: tints 源浓度, device 输出设备,nil使用设备RGB, intent 渲染意图, softMask 是否用于软蒙版组 返回: ColorantResult 独立过程色、专色和备用色, error 浓度或颜色变换错误

func (*ColorantSpace) ResolveInGroup

func (s *ColorantSpace) ResolveInGroup(tints []float64, device *ColorantDevice, group *ColorSpace, intent Name, softMask bool) (ColorantResult, error)

ResolveInGroup 在指定组空间求值过程色,设备专色独立保留,软蒙版只使用备用色 入参: tints 源浓度, device 输出设备,nil使用设备RGB, group 组混合空间,nil继承设备, intent 渲染意图, softMask 是否用于软蒙版组 返回: ColorantResult 组过程色、设备专色与备用色, error 浓度或颜色变换错误

type CompressionLevel

type CompressionLevel uint8

CompressionLevel 选择轻压、均衡或强压,仅用于有损模式

const (
	CompressionLight CompressionLevel = iota
	CompressionMedium
	CompressionStrong
)

有损压缩预设:轻压、均衡和强压

type CompressionMode

type CompressionMode uint8

CompressionMode 选择原始、无损或有损输出策略

const (
	CompressionUnchanged CompressionMode = iota
	CompressionLossless
	CompressionLossy
)

输出压缩模式:原始、无损和有损

type CompressionOptions

type CompressionOptions struct {
	Mode    CompressionMode  `json:"mode"`
	Level   CompressionLevel `json:"level,omitempty"`
	Quality int              `json:"quality,omitempty"`
	MaxDPI  int              `json:"maxDPI,omitempty"`
}

CompressionOptions 配置输出压缩,原始模式沿用现有输出策略,不额外优化 Quality为有损质量1至100,0按Level使用85、60或40 MaxDPI为图片降采样目标1至9600,0按Level使用不限、150或96,不改变页面尺寸

func (CompressionOptions) ImageDPI

func (o CompressionOptions) ImageDPI() int

ImageDPI 返回嵌入图片的降采样目标精度,0表示不降采样 返回: int 目标精度

func (CompressionOptions) ImageQuality

func (o CompressionOptions) ImageQuality() int

ImageQuality 返回有损编码使用的画质 返回: int 编码画质

func (CompressionOptions) Validate

func (o CompressionOptions) Validate() error

Validate 检查压缩档位、画质及精度范围 返回: error 参数错误

type ContentSequence

type ContentSequence struct {
	Reader     *Reader
	Page       *Page
	Stream     *Stream
	Object     Reference
	Tag        Name
	Properties Dictionary
	Parent     *ContentSequence
}

ContentSequence 保存绘制所属的只读内容区段,Parent保留外层区段 PathMark、TextMark和ImageMark通过Sequence引用区段 相邻区段即使标签及属性相同也使用不同实例,区段不随图形状态保存或恢复 Reader用于解析Properties中的间接引用,来源对象沿用阅读器生命周期 Object标识带StructParent的XObject调用或注解外观,此类区段没有Tag和Properties

type Destination

type Destination struct {
	Page       Reference
	Mode       Name
	Parameters Array
}

Destination 保存文档内目标,空参数表示保持阅读器当前值

func (Destination) Transform

func (d Destination) Transform(matrix Matrix) (DestinationTarget, error)

Transform 将PDF目标转换到左上原点坐标,支持缩放、平移和直角旋转,保留空值 入参: matrix 从PDF默认用户空间到目标页面坐标的轴对齐可逆变换 返回: DestinationTarget 变换后的目标, error 模式、参数或变换错误

type DestinationTarget

type DestinationTarget struct {
	Mode                           Name
	Left, Top, Right, Bottom, Zoom float64
	KeepLeft, KeepTop, KeepZoom    bool
}

DestinationTarget 保存左上原点、向右向下坐标中的目标,不依赖窗口或界面 KeepLeft、KeepTop和KeepZoom保留目标中的空值语义,坐标单位由变换矩阵确定

func (DestinationTarget) View

View 按PDF目标语义计算定位与缩放,不限制滚动范围或执行跳转 入参: viewport 当前窗口、视图和内容度量 返回: DestinationView 新视图, error 无效范围、缺少内容度量或计算溢出

type DestinationView

type DestinationView struct {
	Left, Top, Zoom float64
}

DestinationView 保存视口左上位置和缩放率,位置使用未缩放的页面坐标

type DestinationViewport

type DestinationViewport struct {
	Width, Height float64
	Current       DestinationView
	PageBounds    Rectangle
	ContentBounds *Rectangle
}

DestinationViewport 提供目标计算所需的窗口尺寸、当前视图和页面范围 Width和Height与目标坐标采用相同单位,Zoom为1时不缩放;不包含工具栏或页间距 PageBounds为变换后的CropBox,不使用MediaBox或界面外框代替 ContentBounds须由调用方度量,使用变换后的页面坐标,FitB系列不以整页冒充内容范围

type Diagnostic

type Diagnostic struct {
	Page    int
	Offset  int64
	Message string
}

Diagnostic 记录可恢复的问题或未保留的语义,Page从1开始,未知页码为0 Offset为解码后当前页面或表单内容流内的字节位置

type Dictionary

type Dictionary map[Name]Object

Dictionary 保存字典条目,包括未知扩展字段

type DocumentInfo

type DocumentInfo struct {
	Title        string
	Author       string
	Subject      string
	Keywords     string
	Creator      string
	Producer     string
	CreationDate string
	ModDate      string
	Trapped      Name
	Custom       map[Name]string
}

DocumentInfo 保存信息字典中的文本、原始日期与陷印声明,不以XMP覆盖信息字典 Custom保存其他文本字段,每次读取返回独立映射

type EmbeddedFile

type EmbeddedFile struct {
	Name        string
	Description string
	MediaType   string
	Data        []byte
}

EmbeddedFile 保存待写入附件,名称及说明使用UTF-8,MediaType为空时不写媒体类型 Data为原始文件字节,调用期间须保持不变;压缩不改变内容,不自动添加时间等元数据

type EmbeddedTarget

type EmbeddedTarget struct {
	Relation   Name
	Name       *String
	Page       Object
	Annotation Object
}

EmbeddedTarget 保存嵌入目标路径的一步,Relation为P或C Name为名称树原始键;Page为零基页码或命名目标字节串;Annotation为零基索引或文本名称

type EncryptionInfo

type EncryptionInfo struct {
	Revision    int
	Permissions uint32
	Owner       bool
}

EncryptionInfo 保存标准安全处理器版本、用户权限位和所有者认证状态 Permissions采用ISO32000的P字段位定义,Owner为true时不受用户权限限制 阅读器只解析数据,权限控制由调用方实施

type ExternalGoToAction

type ExternalGoToAction struct {
	Type        Name
	File        *FileSpecification
	Destination RemoteDestination
	Target      []EmbeddedTarget
	NewWindow   *bool
}

ExternalGoToAction 保存GoToR或GoToE目标,不执行跳转或读取目标文件 GoToE的File相对于源文档根文件,Target按顺序遍历;NewWindow为空时沿用阅读器偏好

type FileResolver

type FileResolver func(context.Context, FileSpecification) ([]byte, error)

FileResolver 由调用方读取外部文件,库不自动访问网络或本地路径

type FileSpecification

type FileSpecification struct {
	Name        string
	Description string
	Embedded    *Stream
	FileSystem  Name
	Dictionary  Dictionary
}

FileSpecification 保存PDF文件说明,不读取外部文件或访问网络

type Font

type Font struct {
	Name                string
	Subtype             Name
	Program             []byte
	ProgramType         Name
	Dictionary          Dictionary
	BoundingBox         *Rectangle
	FallbackBoundingBox *Rectangle
	Unicode             UnicodeMap
	Vertical            bool
	Recovered           bool
	// contains filtered or unexported fields
}

Font 保存PDF字体程序、字符映射及字宽,不依赖渲染后端 Vertical为true时使用竖排度量,字形本身仍以横排原点描述 BoundingBox保留非Type3字体描述符边界,未提供有效边界时为空 FallbackBoundingBox保留未内嵌标准字体的AFM保守边界,不用于排版,边界单位为千分之一文字空间 Recovered表示已诊断恢复源字体声明,Dictionary仍保留原始字段供调用方保存

func (*Font) Decode

func (f *Font) Decode(data []byte) ([]Glyph, error)

Decode 解码文字串,未知Unicode映射不会以猜测文本替代 入参: data 原始文字字节 返回: []Glyph 字符信息, error 错误信息

func (*Font) DecodeContext

func (f *Font) DecodeContext(ctx context.Context, data []byte) ([]Glyph, error)

DecodeContext 解码文字串并检查取消,不返回不完整的字形列表 入参: ctx 取消上下文, data 原始文字字节 返回: []Glyph 字符信息, error 解码或取消错误

func (*Font) Encode

func (f *Font) Encode(text string) ([]byte, error)

Encode 将Unicode文本编码为源字体字符码,不执行整形、换行或字体替换 优先使用可完整编码的单字符序列;缺少映射或字形时返回错误,不返回部分结果 入参: text Unicode文本 返回: []byte 可用于该字体文字显示操作的字符码, error 编码错误

func (*Font) EncodeContext

func (f *Font) EncodeContext(ctx context.Context, text string) ([]byte, error)

EncodeContext 将Unicode文本编码为源字体字符码,编码过程可取消 入参: ctx 取消上下文, text Unicode文本 返回: []byte 可用于该字体文字显示操作的字符码, error 编码或取消错误

func (*Font) EncodeGlyphs

func (f *Font) EncodeGlyphs(glyphs []uint16) ([]byte, error)

EncodeGlyphs 将内嵌字体的字形编号转换为源字体字符码,不修改字体资源 字形须由源编码直接访问,不使用缺省字形;原文语义和字形定位由调用方保留 入参: glyphs 字形编号序列 返回: []byte 文字显示操作的字符码, error 缺少编码或字形错误

func (*Font) EncodeGlyphsContext

func (f *Font) EncodeGlyphsContext(ctx context.Context, glyphs []uint16) ([]byte, error)

EncodeGlyphsContext 按源字体编码字形序列,失败或取消时不返回部分结果 入参: ctx 取消上下文, glyphs 字形编号序列 返回: []byte 文字显示操作的字符码, error 编码或取消错误

func (*Font) GlyphFont

func (f *Font) GlyphFont(glyphs []GlyphWidth) (*Font, error)

GlyphFont 复用内嵌程序建立横排复合字体,使指定字形不受源字符编码限制 返回字体仅编码指定字形,Dictionary可作为同一阅读器中的字体资源,原文语义和定位由调用方保留 不修改源字典、字符映射或字体程序;调用方提供的字宽须与字体程序一致 入参: glyphs 所需字形与字宽 返回: *Font 新字体, error 字体或度量错误

func (*Font) GlyphFontContext

func (f *Font) GlyphFontContext(ctx context.Context, glyphs []GlyphWidth) (*Font, error)

GlyphFontContext 构造可直接编码指定字形的字体,失败或取消时不返回部分资源 入参: ctx 取消上下文, glyphs 所需字形与字宽 返回: *Font 新字体, error 字体、度量或取消错误

func (*Font) GlyphMap

func (f *Font) GlyphMap() (map[rune]uint16, error)

GlyphMap 汇总Unicode单字符到内嵌字体字形编号的映射,不拆分多字符映射 无法确定字形编号的字符不纳入结果,返回的映射可由调用方独立修改 返回: map[rune]uint16 字符与字形编号, error 映射错误

func (*Font) GlyphMapContext

func (f *Font) GlyphMapContext(ctx context.Context) (map[rune]uint16, error)

GlyphMapContext 按取消上下文汇总单字符字形映射,显式ToUnicode优先 入参: ctx 取消上下文 返回: map[rune]uint16 独立字形映射, error 映射或取消错误

type FormMark

type FormMark struct {
	Bounds Rectangle
	Matrix Matrix
}

FormMark 保存普通表单的局部边界及到页面坐标的变换,不代表透明组

type FunctionGradient

type FunctionGradient struct {
	Domain        Rectangle
	Matrix        Matrix
	PatternMatrix Matrix
	Space         *ColorSpace
	Intent        Name
	Background    *[4]float64
	Bounds        *Rectangle
	// contains filtered or unexported fields
}

FunctionGradient 保存二维函数着色的定义域、源颜色及坐标变换 Matrix将定义域映射到页面,PatternMatrix将着色坐标映射到页面 Background及Bounds仅用于着色图案,Bounds使用着色坐标

func (*FunctionGradient) ColorAt

func (g *FunctionGradient) ColorAt(point Point) ([3]float64, error)

ColorAt 计算定义域坐标的颜色,再按渲染意图转换为sRGB 入参: point 定义域坐标,不含Matrix变换 返回: [3]float64 sRGB颜色, error 坐标或颜色变换错误

func (*FunctionGradient) ColorantAt

func (g *FunctionGradient) ColorantAt(point Point) (*ColorantPaint, error)

ColorantAt 求值二维函数渐变的原始色料,不预先转换到组混合空间 入参: point 定义域坐标,不含Matrix变换 返回: *ColorantPaint 色料快照,非色料渐变为nil, error 参数或函数错误

func (*FunctionGradient) ColorantSpace

func (g *FunctionGradient) ColorantSpace() *ColorantSpace

ColorantSpace 返回函数着色的只读原始色料定义 返回: *ColorantSpace 色料定义,普通颜色空间为nil

func (*FunctionGradient) ColorantValuesAt

func (g *FunctionGradient) ColorantValuesAt(point Point, out []float64) error

ColorantValuesAt 求值二维源函数并裁切浓度,不经过备用色变换 入参: point 定义域坐标, out 与色料数等长的输出缓冲 返回: error 非色料渐变、参数或函数错误,错误时不保证缓冲内容

func (*FunctionGradient) ValuesAt

func (g *FunctionGradient) ValuesAt(point Point) ([4]float64, error)

ValuesAt 按定义域内坐标计算源颜色分量,定义域外使用边界坐标 入参: point 定义域坐标,不含Matrix变换 返回: [4]float64 源颜色或备用空间分量, error 坐标或求值错误

type Glyph

type Glyph struct {
	Name      string
	Code      uint32
	Text      string
	CID       uint16
	ID        uint16
	HasID     bool
	Width     float64
	Vertical  VerticalMetrics
	WordSpace bool
}

Glyph 保存原始字符码、Unicode文本、字形名称、编号和千分之一字宽 缺少Unicode映射但具有字形编号或未定义字形时,Text为空,不推测字符含义 CID保留复合字体字符标识,只有可确定内嵌字形编号时HasID才为true Vertical仅在竖排字体中有效,Width始终保留横排字宽

type GlyphWidth

type GlyphWidth struct {
	ID    uint16
	Width float64
}

GlyphWidth 指定内嵌字形及其字体程序字宽,单位为千分之一字号 Width不含字距、字偶调整或整形偏移,不以整形后的推进量代替

type GradientPosition

type GradientPosition struct {
	// contains filtered or unexported fields
}

GradientPosition 保存只读渐变几何,独立于颜色函数及着色图案边界

func (GradientPosition) PositionAt

func (g GradientPosition) PositionAt(point Point) (float64, bool)

PositionAt 按页面点求参数,双圆多解取半径非负且符合Extend的最大参数 入参: point 页面坐标 返回: float64 归一化参数, bool 是否处于着色范围

type GradientStop

type GradientStop struct {
	Position float64
	RGB      [3]float64
	Values   [4]float64
}

GradientStop 保存渐变位置、源空间分量及对应sRGB颜色 RGB仅表示断点颜色,区间颜色应通过渐变的ColorAt方法计算

type GroupMark

type GroupMark struct {
	Page            bool
	Alpha           float64
	AlphaIsShape    bool
	Isolated        bool
	Knockout        bool
	BlendMode       Name
	SoftMask        *SoftMask
	ColorSpace      *ColorSpace
	ColorConversion ColorConversion
	RenderingIntent Name
}

GroupMark 保存透明度组的边界不透明度和隔离方式,组内绘制使用独立状态 Page区分页面初始组与内容流中的表单组

type Halftone

type Halftone struct {
	Type                           int
	Name                           []byte
	Dictionary                     Dictionary
	Frequency, Angle               float64
	SpotFunction                   Object
	TransferFunction               Object
	AccurateScreens                bool
	Width, Height, Width2, Height2 int
	Xsquare, Ysquare               int
	Thresholds                     []uint16
	Components                     map[Name]*Halftone
	// contains filtered or unexported fields
}

Halftone 保存设备空间半色调定义,连续色调显示不需要网屏化 Thresholds保持标准中的数组顺序,类型16使用高位优先的16位阈值

func (*Halftone) IdentityTransfer

func (h *Halftone) IdentityTransfer(reader *Reader) (bool, error)

IdentityTransfer 判断网屏中是否仅使用恒等传递函数,分量网屏逐项检查 入参: reader 无所属阅读器时使用的PDF阅读器 返回: bool 是否恒等, error 函数解析错误

type HalftoneOptions

type HalftoneOptions struct {
	Resolution    float64
	Bits          int
	Colorant      Name
	Transfer      Object
	Named         map[string]*Halftone
	MaxCellPixels int
	Origin        image.Point
}

HalftoneOptions 保存设备网屏参数,分量值采用黑零白一的加色形式 Origin指定设备像素原点,不自动换算用户坐标或分辨率

type HalftoneScreen

type HalftoneScreen struct {
	// contains filtered or unexported fields
}

HalftoneScreen 保存独立于阅读器的设备网屏,编译后可并发读取

func (*HalftoneScreen) Apply

func (s *HalftoneScreen) Apply(ctx context.Context, source *image.Gray16) (*image.Gray16, error)

Apply 对单个加色分量进行网屏化,保持原始设备坐标及子图边界 入参: ctx 取消上下文, source 16位连续分量图像 返回: *image.Gray16 网屏化图像, error 取消或空图像错误

func (*HalftoneScreen) Quantize

func (s *HalftoneScreen) Quantize(value uint16, x, y int) uint16

Quantize 将16位连续分量量化为设备等级,坐标始终处于设备空间 入参: value 黑零白满的分量值, x 横向设备坐标, y 纵向设备坐标 返回: uint16 归一化后的设备分量值

func (*HalftoneScreen) QuantizeRow

func (s *HalftoneScreen) QuantizeRow(ctx context.Context, out, values []uint16, x, y int) error

QuantizeRow 量化一行加色分量,支持重叠缓冲区且不分配像素内存 入参: ctx 取消上下文, out 输出分量, values 源分量, x 起始设备横坐标, y 设备纵坐标 返回: error 取消、尺寸或坐标错误,取消时输出可能已部分更新

type HideAction

type HideAction struct {
	Targets []ActionTarget
	Hide    bool
}

HideAction 保存注解或表单字段的显示动作,不改变可见性

type Image

type Image struct {
	Width            int
	Height           int
	BitsPerComponent int
	ColorSpace       Object
	Intent           Name
	Decode           Array
	ImageMask        bool
	Interpolate      bool
	Mask             Object
	SoftMask         Object
	Stream           *Stream
	Warning          func(Diagnostic)
	// contains filtered or unexported fields
}

Image 保存图像有效属性及原始数据流,颜色空间和遮罩使用PDF对象 Warning非空时允许恢复完整图像的尺寸、Decode、遮罩及编码封装差异,并报告原因 Intent为空时继承绘图状态,单独解码使用相对色度

func (*Image) ColorSpaceComponents

func (i *Image) ColorSpaceComponents() (int, error)

ColorSpaceComponents 读取源样本通道数,Indexed为1,不包含透明度或备用空间通道 仅校验通道定义,不解码图像、ICC配置或颜色变换;资源空间由ReadImageWithResources解析 返回: int 源通道数,模板为1,未取得空间时为0, error 引用或通道定义错误

func (*Image) ColorSpaceFamily

func (i *Image) ColorSpaceFamily() (Name, error)

ColorSpaceFamily 读取源颜色空间族,不将索引基础空间或分色备用空间替代源定义 返回: Name 空间族,模板或未取得空间时为空, error 引用或空间类型错误

func (*Image) ColorantSpace

func (i *Image) ColorantSpace() (*ColorantSpace, error)

ColorantSpace 读取图像或索引基础空间的只读色料定义及独立专色变换 返回: *ColorantSpace 色料定义,非色料空间为nil, error 颜色空间错误

func (*Image) Colorants

func (i *Image) Colorants() ([]Name, error)

Colorants 读取图像或索引基础空间的专色名称,设备色返回空列表 返回: []Name 色料名称, error 颜色空间格式错误

func (*Image) DecodeComponents

func (i *Image) DecodeComponents() (*ImageComponents, error)

DecodeComponents 读取已映射分量,专色保留备用空间及浓度,Lab映射为RGB 返回: *ImageComponents 颜色分量及透明度, error 解码或不支持的源空间错误

func (*Image) DecodeComponentsContext

func (i *Image) DecodeComponentsContext(ctx context.Context) (*ImageComponents, error)

DecodeComponentsContext 读取映射后的颜色分量及遮罩,逐行检查取消 入参: ctx 取消上下文 返回: *ImageComponents 独立颜色分量及透明度, error 解码或取消错误

func (*Image) DecodeComponentsView

func (i *Image) DecodeComponentsView() (*ImageComponents, error)

DecodeComponentsView 读取原生分量的只读视图,设备色和模板图像保持按需访问 Pix可为空,使用ValuesAt采样;其他空间保留备用、过程和专色分量 返回: *ImageComponents 只读颜色分量及透明度, error 解码错误

func (*Image) DecodeComponentsViewContext

func (i *Image) DecodeComponentsViewContext(ctx context.Context) (*ImageComponents, error)

DecodeComponentsViewContext 解码原始样本并按需读取设备色,不保留取消上下文 入参: ctx 解码取消上下文 返回: *ImageComponents 只读颜色分量及透明度, error 解码或取消错误

func (*Image) DecodeImage

func (i *Image) DecodeImage() (image.Image, error)

DecodeImage 应用Decode映射及颜色空间变换,合成遮罩后返回非预乘透明图像 模板图像返回映射后的灰度样本,当前填充色由页面使用方应用 异尺寸遮罩按单位方形对齐,输出尺寸取各轴较大的采样数以保留边缘精度 返回: image.Image 解码图像, error 错误信息

func (*Image) DecodeImageContext

func (i *Image) DecodeImageContext(ctx context.Context) (image.Image, error)

DecodeImageContext 解码图像及遮罩,在读取和逐行映射之间检查取消 返回图像的后续延迟采样由调用方管理,不持有取消上下文 入参: ctx 取消上下文 返回: image.Image 解码图像, error 解码或取消错误

func (*Image) DecodeImageSizeContext

func (i *Image) DecodeImageSizeContext(ctx context.Context, size image.Point) (image.Image, error)

DecodeImageSizeContext 按显式像素需求解码并等比缩小,不改变原始图像描述 JPEG2000设备色及校准色可提前裁减高分辨率层;外部遮罩及索引色先按完整样本解释 零值或非正需求保持完整尺寸,缩小结果不用于无损输出 入参: ctx 取消上下文, size 两轴像素需求 返回: image.Image 显示图像, error 参数、解码或取消错误

func (*Image) DecodeProcess

func (i *Image) DecodeProcess(device *ColorantDevice, group *ColorSpace, softMask bool) (*ImageProcess, error)

DecodeProcess 只解码设备可直接使用的原生过程通道,不生成备用颜色缓冲 入参: device 输出设备, group 组混合空间,nil继承设备, softMask 是否用于软蒙版 返回: *ImageProcess 原生采样,需要备用色时为nil, error 解码或布局错误

func (*Image) DecodeProcessContext

func (i *Image) DecodeProcessContext(ctx context.Context, device *ColorantDevice, group *ColorSpace, softMask bool) (*ImageProcess, error)

DecodeProcessContext 共用源样本和遮罩解码,保留16位浓度及源透明度 入参: ctx 解码取消上下文, device 输出设备, group 组混合空间,nil继承设备, softMask 是否用于软蒙版 返回: *ImageProcess 独立只读采样,需要备用色时为nil, error 解码或取消错误

func (*Image) DecodeSamples

func (i *Image) DecodeSamples() (image.Image, error)

DecodeSamples 解码原始图像样本,不应用Decode数组、遮罩或色彩管理 返回的灰度值用于样本解释,不代表图像已完成页面合成 CMYK图像还原DCT分量,取消通用JPEG解码器的Adobe反相处理 返回: image.Image 样本图像, error 错误信息

func (*Image) DecodeSamplesContext

func (i *Image) DecodeSamplesContext(ctx context.Context) (image.Image, error)

DecodeSamplesContext 解码原始样本,在流读取及样本处理之间检查取消 JPEG2000解码过程中可取消,JBIG2内部运算完成后检查取消 入参: ctx 取消上下文 返回: image.Image 独立原始样本, error 解码或取消错误

func (*Image) EncodePNGContext

func (i *Image) EncodePNGContext(ctx context.Context, writer io.Writer) error

EncodePNGContext 按原始尺寸无损导出图像,颜色、遮罩及精度与DecodeImageContext一致 JPEG2000按行带解码,校准色逐行转换,不分配整幅显示缓冲;取消或失败时输出可能不完整 入参: ctx 取消上下文, writer PNG输出流 返回: error 参数、解码、颜色或写入错误

func (*Image) HasMask

func (i *Image) HasMask() (bool, error)

HasMask 判断模板、显式、色键及JPEG2000内嵌遮罩,空引用不构成遮罩 不解码像素,也不判断遮罩是否全不透明 返回: bool 是否具有生效遮罩, error 引用或遮罩参数错误

func (*Image) HasSoftMask

func (i *Image) HasSoftMask() (bool, error)

HasSoftMask 判断显式及JPEG2000内嵌软遮罩,不将硬遮罩当作软遮罩 返回: bool 是否具有软遮罩, error 引用或遮罩参数错误

func (*Image) JBIG2File

func (i *Image) JBIG2File() ([]byte, error)

JBIG2File 无损封装可直接复用的单页JBIG2图像及全局段 不适合直接复用的图像返回nil,调用DecodeImage可得到已应用颜色与遮罩的像素 返回: []byte 完整JBIG2文件, error 解码参数或资源错误

func (*Image) JBIG2FileContext

func (i *Image) JBIG2FileContext(ctx context.Context) ([]byte, error)

JBIG2FileContext 无损封装单页JBIG2,前置过滤器与全局段解码期间检查取消 入参: ctx 取消上下文 返回: []byte 完整JBIG2文件或空值, error 参数、编码或取消错误

func (*Image) JPEGFile

func (i *Image) JPEGFile() ([]byte, error)

JPEGFile 返回可脱离PDF字典直接显示的JPEG,移除PDF忽略的方向和配置文件 返回: []byte 未重编码的JPEG或空值, error 解码参数错误

func (*Image) JPEGFileContext

func (i *Image) JPEGFileContext(ctx context.Context) ([]byte, error)

JPEGFileContext 返回可直接复用的JPEG,移除显示元数据期间检查取消 入参: ctx 取消上下文 返回: []byte 未重编码的JPEG或空值, error 参数、编码或取消错误

func (*Image) ProcessColorants

func (i *Image) ProcessColorants() (*ProcessColorants, error)

ProcessColorants 读取图像或索引基础空间的原生过程通道 返回: *ProcessColorants 只读过程映射,非原生映射为nil, error 颜色空间错误

type ImageComponents

type ImageComponents struct {
	Space         *ColorSpace
	Process       *ProcessColorants
	ColorantSpace *ColorantSpace
	Rect          image.Rectangle
	Pix           []uint16
	Colorants     []Name
	Tints         []uint16
	ColorantAlpha []uint16
	// contains filtered or unexported fields
}

ImageComponents 保存应用Decode、索引映射及遮罩后的16位非预乘颜色分量 Pix逐行交错保存Space.Components()个颜色分量和一个透明度分量 DecodeComponentsView的设备色缓冲可为空,使用ValuesAt读取只读分量 模板图像保留灰度样本,填充颜色及反向覆盖由调用方应用 Colorants和Tints保留专色名称及逐像素浓度,供支持相应色料的输出设备使用 Process保留原生过程通道,ValuesAt返回对应过程空间的颜色分量 ColorantAlpha仅在备用色None时保存源遮罩,nil时复用Pix透明度,避免重复缓冲

func (*ImageComponents) PrepareProcess

func (i *ImageComponents) PrepareProcess(device *ColorantDevice, group *ColorSpace, softMask bool) (*ImageProcess, error)

PrepareProcess 校验图像布局并编译原生过程通道,原始浓度与源透明度独立于备用色 入参: device 输出设备, group 组混合空间,nil继承设备, softMask 是否用于软蒙版 返回: *ImageProcess 原生采样,需备用色或独立专色时为nil, error 像素布局错误

func (*ImageComponents) ResolveColorantsAt

func (i *ImageComponents) ResolveColorantsAt(x, y int, device *ColorantDevice, intent Name, softMask bool) (ColorantResult, float64, error)

ResolveColorantsAt 按输出设备求值像素的源色料,透明度使用源遮罩而非备用色覆盖 入参: x 横坐标, y 纵坐标, device 输出设备, intent 渲染意图, softMask 是否用于软蒙版组 返回: ColorantResult 原生和备用色料, float64 源透明度, error 色料或变换错误

func (*ImageComponents) ResolveColorantsInGroupAt

func (i *ImageComponents) ResolveColorantsInGroupAt(x, y int, group *ColorantGroup, intent Name, softMask bool) (ColorantResult, float64, error)

ResolveColorantsInGroupAt 在透明组空间求值像素,不将设备过程分量误用于其他组空间 入参: x 横坐标, y 纵坐标, group 组定义, intent 渲染意图, softMask 是否用于软蒙版组 返回: ColorantResult 组过程色、原生及备用专色, float64 源透明度, error 缓冲、定义或变换错误

func (*ImageComponents) TintsAt

func (i *ImageComponents) TintsAt(x, y int) []uint16

TintsAt 返回原始专色的已映射浓度,区域外或无专色时返回nil 入参: x 横坐标, y 纵坐标 返回: []uint16 非预乘浓度,返回切片只读

func (*ImageComponents) ValuesAt

func (i *ImageComponents) ValuesAt(x, y int) ([4]float64, float64)

ValuesAt 返回像素的单位颜色分量及透明度,区域外返回透明值 入参: x 横坐标, y 纵坐标 返回: [4]float64 非预乘颜色, float64 透明度

type ImageMark

type ImageMark struct {
	Sequence *ContentSequence
	Image    *Image
	Matrix   Matrix
	Style    Style
}

ImageMark 保存图像资源及单位方形到页面坐标的变换

type ImageProcess

type ImageProcess struct {
	// contains filtered or unexported fields
}

ImageProcess 保存已校验的原生图像采样,源分量和色料定义在使用期间须保持只读 不复制像素缓冲,可并发采样,不执行备用变换或图像插值

func (*ImageProcess) Bounds

func (p *ImageProcess) Bounds() image.Rectangle

Bounds 返回原始采样边界,不将非零原点归零 返回: image.Rectangle 源边界,未初始化时为空

func (*ImageProcess) Mask

func (p *ImageProcess) Mask() [4]bool

Mask 返回显式指定的过程通道,零浓度仍标记对应通道 返回: [4]bool 原生过程通道

func (*ImageProcess) ValuesAt

func (p *ImageProcess) ValuesAt(x, y int) ([4]float64, float64)

ValuesAt 从原始16位浓度直接取样,不分配浓度快照或逐像素解析颜色定义 入参: x 横坐标, y 纵坐标 返回: [4]float64 原生过程分量, float64 源透明度,无效采样或区域外返回透明

type ImageWriteOptions

type ImageWriteOptions struct {
	PreblendBinary bool
}

ImageWriteOptions 保存图像创建与替换参数 PreblendBinary对二值透明图像采用标准Matte预混合,保留可见颜色,透明像素的隐藏颜色不保留

type ImportDataAction

type ImportDataAction struct {
	File FileSpecification
}

ImportDataAction 保存FDF导入目标,不读取文件或修改表单

type Integer

type Integer int64

Integer 表示整数对象

type JavaScriptAction

type JavaScriptAction struct {
	Script string
}

JavaScriptAction 保存脚本文字,不解释或执行JavaScript

type LaunchAction

type LaunchAction struct {
	File      *FileSpecification
	Windows   *WindowsLaunchParameters
	Mac, Unix Object
	NewWindow *bool
}

LaunchAction 保存文件启动动作,不执行应用程序、打印或访问外部文件 File为跨平台后备目标,平台参数优先;Mac和Unix保留标准未定义的只读原始值 NewWindow为空时使用阅读器偏好,仅对PDF目标文档有效

type LinkRegion

type LinkRegion struct {
	Rect  Rectangle
	Quads [][4]Point
}

LinkRegion 描述默认用户空间中的链接矩形和点击区域 Rect须为非空有限矩形;Quads为逆时针凸四边形,全部顶点须位于Rect内 Quads为空时使用整个Rect,不同四边形的点击区域取并集

type MarkedContentMark

type MarkedContentMark struct {
	Reader      *Reader
	Page        *Page
	Stream      *Stream
	Sequence    *ContentSequence
	Tag         Name
	Properties  Dictionary
	Operator    string
	Offset      int64
	Replacement *ReplacementText
	Hidden      bool
}

MarkedContentMark 保存内容标记及其属性,结束标记沿用开始标记的标签 Replacement在含ActualText的Span开始和结束时共享实例,Hidden表示区段当前不可见 Offset为当前解码内容流中的操作位置 Page标识来源页面,Stream为空表示页面合并内容,否则标识Form、字形或图案内容流 来源对象沿用阅读器生命周期,独立构造的绘制输入可能没有Page Sequence在区段开始和结束时共享实例,MP和DP不创建区段 Reader用于解析Properties中的间接引用,包括不创建区段的点标记

type Matrix

type Matrix [6]float64

Matrix 表示PDF二维仿射矩阵,使用列向量坐标约定

func Identity

func Identity() Matrix

Identity 返回单位矩阵 返回: Matrix 单位矩阵

func (Matrix) Apply

func (m Matrix) Apply(p Point) Point

Apply 将点变换到目标坐标空间 入参: p 原始坐标点 返回: Point 变换后的坐标点

func (Matrix) Inverse

func (m Matrix) Inverse() (Matrix, bool)

Inverse 返回可逆仿射矩阵的逆变换 返回: Matrix 逆矩阵, bool 是否存在有限逆矩阵

func (Matrix) MaxScale

func (m Matrix) MaxScale() float64

MaxScale 返回线性部分的最大伸长率,包含剪切且不受平移影响 返回: float64 最大奇异值,非有限变换返回非有限值

func (Matrix) Mul

func (m Matrix) Mul(n Matrix) Matrix

Mul 按当前矩阵乘以右侧矩阵进行坐标组合 入参: n 右侧矩阵 返回: Matrix 组合矩阵

type MediaAsset

type MediaAsset struct {
	Name string
	File FileSpecification
}

MediaAsset 保存名称树中的媒体文件及其原始文件说明

type MediaClip

type MediaClip struct {
	Subtype     Name
	Name        string
	ContentType string
	File        *FileSpecification
	Form        *Stream
	Section     *MediaClip
	Permissions Dictionary
	Players     Dictionary
	MustHonor   Dictionary
	BestEffort  Dictionary
	Dictionary  Dictionary
}

MediaClip 保存媒体数据、嵌套片段及必须遵守的播放约束

type MediaConfiguration

type MediaConfiguration struct {
	Reference  Reference
	Subtype    Name
	Instances  []MediaInstance
	Dictionary Dictionary
}

MediaConfiguration 保存媒体实例组合及其原始配置

type MediaInstance

type MediaInstance struct {
	Subtype    Name
	Asset      FileSpecification
	Parameters Dictionary
	Dictionary Dictionary
}

MediaInstance 保存实例类型、媒体文件和运行参数

type MeshGradient

type MeshGradient struct {
	Patches    []MeshPatch
	Triangles  []MeshTriangle
	Matrix     Matrix
	Space      *ColorSpace
	Intent     Name
	Background *[4]float64
	Bounds     *Rectangle
	// contains filtered or unexported fields
}

MeshGradient 保存曲面或三角网格,各切片保持绘制顺序,Matrix将网格坐标映射到页面 Background和Bounds仅用于着色图案,直接着色的边界由裁剪路径表达

func (*MeshGradient) ColorantAt

func (g *MeshGradient) ColorantAt(patch int, u, v float64) (*ColorantPaint, error)

ColorantAt 先插值网格源分量并求值函数,再保留色料浓度快照 入参: patch 网格序号, u 横向参数或第二顶点权重, v 纵向参数或第三顶点权重 返回: *ColorantPaint 色料快照,非色料网格为nil, error 参数或函数错误

func (*MeshGradient) ColorantSpace

func (g *MeshGradient) ColorantSpace() *ColorantSpace

ColorantSpace 返回网格着色的只读原始色料定义 返回: *ColorantSpace 色料定义,普通颜色空间为nil

func (*MeshGradient) ColorantValuesAt

func (g *MeshGradient) ColorantValuesAt(patch int, u, v float64, out []float64) error

ColorantValuesAt 插值网格源分量并求值函数,不分配浓度快照 入参: patch 网格序号, u 横向参数, v 纵向参数, out 与色料数等长的输出缓冲 返回: error 非色料渐变、参数或函数错误,错误时不保证缓冲内容

func (*MeshGradient) LinearColors

func (g *MeshGradient) LinearColors(index int) ([3][4]float64, error)

LinearColors 返回可直接用于线性插值的三角形顶点颜色,不改变源网格 入参: index 三角形索引,不计曲面数量 返回: [3][4]float64 Space颜色空间分量, error 参数错误或无法确认等价转换的UnsupportedError

func (*MeshGradient) LinearTriangles

func (g *MeshGradient) LinearTriangles(index int) ([]MeshTriangle, error)

LinearTriangles 将连续分段线性颜色函数及专色变换展开为三角形,不改变源网格 入参: index 三角形索引,不计曲面数量 返回: []MeshTriangle 使用Space颜色分量且无需再求值函数的三角形, error 参数错误或无法等价展开的UnsupportedError

func (*MeshGradient) LinearTrianglesContext

func (g *MeshGradient) LinearTrianglesContext(ctx context.Context, index int) ([]MeshTriangle, error)

LinearTrianglesContext 展开连续分段线性网格,取消或失败时不返回部分结果 入参: ctx 取消上下文, index 三角形索引,不计曲面数量 返回: []MeshTriangle 使用Space颜色分量的独立三角形, error 参数、转换或取消错误

func (*MeshGradient) NewSampler

func (g *MeshGradient) NewSampler() *MeshSampler

NewSampler 创建独立的网格采样器,不修改网格或共享函数 返回: *MeshSampler 网格采样器

func (*MeshGradient) UsesFunction

func (g *MeshGradient) UsesFunction() bool

UsesFunction 判断颜色分量是否需在插值后经过函数变换 返回: bool 是否使用颜色函数

func (*MeshGradient) ValuesAt

func (g *MeshGradient) ValuesAt(patch int, u, v float64) ([4]float64, error)

ValuesAt 插值源分量后依次执行着色函数和专色变换,三角形编号接在曲面之后 入参: patch 网格序号, u 横向参数或第二顶点权重, v 纵向参数或第三顶点权重 返回: [4]float64 Space颜色空间分量, error 参数或颜色错误

type MeshPatch

type MeshPatch struct {
	Points [4][4]Point
	Colors [4][]float64
}

MeshPatch 保存双三次曲面控制点及四角分量,Points按u、v索引 Colors依次对应(0,0)、(0,1)、(1,1)、(1,0),有着色函数时仅首分量为函数输入

func (MeshPatch) PointAt

func (p MeshPatch) PointAt(u, v float64) Point

PointAt 计算单位参数域内的双三次曲面坐标 入参: u 横向参数, v 纵向参数 返回: Point 网格坐标

type MeshSampler

type MeshSampler struct {
	// contains filtered or unexported fields
}

MeshSampler 复用网格颜色函数,备用色与原始浓度各缓存最多1024项 使用期间网格应保持只读;并发采样应分别创建采样器

func (*MeshSampler) ColorantValuesAt

func (s *MeshSampler) ColorantValuesAt(patch int, u, v float64, out []float64) error

ColorantValuesAt 复用常见色料函数的精确输入结果,不混用备用颜色缓存 入参: patch 网格序号, u 横向参数, v 纵向参数, out 与色料数等长的输出缓冲 返回: error 非色料渐变、参数或函数错误,错误时不保证缓冲内容

func (*MeshSampler) ValuesAt

func (s *MeshSampler) ValuesAt(patch int, u, v float64) ([4]float64, error)

ValuesAt 插值网格分量并复用完全相同的函数输入,不缓存失败结果 入参: patch 网格序号, u 横向参数或第二顶点权重, v 纵向参数或第三顶点权重 返回: [4]float64 Space颜色空间分量, error 参数或颜色错误

type MeshTriangle

type MeshTriangle struct {
	Points [3]Point
	Colors [3][]float64
}

MeshTriangle 保存Gouraud三角形顶点及对应颜色分量

type Movie

type Movie struct {
	File          FileSpecification
	Width, Height float64
	Rotate        int
	Poster        Object
}

Movie 保存视频文件说明、显示参数和海报,不解码媒体或执行播放

type MovieAction

type MovieAction struct {
	Annotation Reference
	Target     *MovieAnnotation
	Title      string
	Operation  Name
	Activation Dictionary
}

MovieAction 保存视频目标和播放操作,Activation中的显式值覆盖目标注解的参数 Annotation和Title指定原有目标,Target用于写入时引用本次新增的视频注解,不可同时指定 未声明参数需由调用方结合目标注解解析

type MovieActivation

type MovieActivation struct {
	Start, Duration           *MovieTime
	Rate, Volume              float64
	ShowControls, Synchronous bool
	Mode                      Name
	FloatingScale             *[2]int64
	FloatingPosition          [2]float64
}

MovieActivation 保存视频播放参数,不播放媒体或读取外部文件 Start为空表示从头播放,Duration为空表示播放至结尾,FloatingScale为空表示嵌入显示

type MovieAnnotation

type MovieAnnotation struct {
	Rect       Rectangle
	Title      string
	Movie      *Movie
	Activation Object
}

MovieAnnotation 描述新增视频注解,Rect使用默认用户空间,Title使用UTF-8文字 Movie指针相同的注解复用视频资源,源数据在写出期间须保持可读 Activation接受nil、Boolean或Dictionary;nil采用标准默认播放,false关闭注解自身的点击播放 播放参数中的引用须属于当前文件;海报接受Boolean或图像流,流引用随所属Reader解析 文件说明按结构化字段写出,Dictionary不参与写出,不自动添加时间或作者信息

type MoviePlayback

type MoviePlayback struct {
	Annotation Annotation
	Movie      Movie
	Operation  Name
	Activation MovieActivation
}

MoviePlayback 保存动作目标、视频资源及合并后的播放参数,不读取文件或执行播放

type MovieTime

type MovieTime struct {
	Value int64
	Scale int64
}

MovieTime 保存非负视频时间,Scale为0表示使用媒体自身的时间单位

type Name

type Name string

Name 表示已解除转义的名称,不包含起始斜线

type NavigationAction struct {
	Destination *Destination
	External    *ExternalGoToAction
	Attachment  *AttachmentAction
	Sound       *SoundAction
	Movie       *MovieAction
	Rendition   *RenditionAction
	URI         string
}

NavigationAction 描述导航或媒体播放动作,须且仅须指定一项 URI使用UTF-8文字或已转义地址,写出时转换为ASCII,不访问外部资源 External按结构化字段写出,File.Dictionary不参与写出,File.Name使用标准文件路径或URL Sound的音量零值为静音,源流及文件数据在写出期间须保持可读;库不执行播放 Movie须指向原文件或本次新增的视频注解,跨页播放须由调用方先指定跳转动作 Movie未指定Annotation和Target时按Title查找原注解,允许空标题;Activation仅写出显式参数 Movie.Activation中的间接引用须属于当前文件 Rendition引用原有或本次新增的屏幕注解,不执行脚本或播放媒体

type Object

type Object interface {
	// contains filtered or unexported methods
}

Object 表示PDF对象,空对象使用nil表示

type OpenAction

type OpenAction struct {
	Destination *Destination
	Action      Dictionary
}

OpenAction 区分文档初始目标与打开动作,均为空时使用阅读器默认视图

type Operation

type Operation struct {
	Operator string
	Operands []Object
	Offset   int64
}

Operation 保存内容流操作符及其操作数,不解释或执行操作 BI操作将完整内联图像作为唯一的Stream操作数交付,字典缩写已展开

type OptimizeOptions

type OptimizeOptions struct {
	Compression CompressionOptions
	Creator     string
	OnProgress  func(stage string, completed, total int) error
}

OptimizeOptions 配置原生PDF重写,不经过页面渲染 原始模式或包含签名时保留源文件;加密文档保留原安全处理器、密码和权限 Creator非空时设置重写结果的制作软件;OnProgress回报scan、compress、write阶段,支持取消

type OptimizeReport

type OptimizeReport struct {
	Bytes     int64
	Objects   int
	Streams   int
	Preserved bool
}

OptimizeReport 汇总原生PDF优化结果,Preserved表示源文件原样写出

type OutlineItem

type OutlineItem struct {
	Reference   Reference
	Title       string
	Expanded    bool
	Bold        bool
	Italic      bool
	Color       [3]float64
	Destination Object
	Action      Object
	Dictionary  Dictionary
}

OutlineItem 保存目录标题、显示样式及原始跳转声明,不执行动作

type OutputIntent

type OutputIntent struct {
	Subtype                   Name
	OutputCondition           string
	OutputConditionIdentifier string
	RegistryName              string
	Info                      string
	Profile                   []byte
	Space                     *ColorSpace
}

OutputIntent 保存目标输出条件和独立ICC快照,不替代对象颜色空间或启用屏幕打样

type Page

type Page struct {
	Reference  Reference
	Dictionary Dictionary
	Resources  Dictionary
	MediaBox   Rectangle
	CropBox    Rectangle
	Rotation   int
	UserUnit   float64
	// contains filtered or unexported fields
}

Page 保存页面字典及继承后生效的页面属性

func (*Page) Annotations

func (p *Page) Annotations() ([]Annotation, error)

Annotations 按页面顺序读取注解,外观和动作由调用方解释 返回: []Annotation 注解信息, error 错误信息

func (*Page) AnnotationsContext

func (p *Page) AnnotationsContext(ctx context.Context) ([]Annotation, error)

AnnotationsContext 按页面顺序读取注解,取消或解析失败时不返回部分结果 入参: ctx 取消上下文 返回: []Annotation 注解信息, error 错误信息

func (*Page) Content

func (p *Page) Content() ([]byte, error)

Content 读取并依次连接页面内容流,保留流间的图形状态语义 返回: []byte 内容操作符数据, error 错误信息

func (*Page) WriteContent

func (p *Page) WriteContent(ctx context.Context, writer io.Writer) (int64, error)

WriteContent 逐个解码并输出页面内容流,以换行分隔,不拼接整页内容;单个流仍完整解码 入参: ctx 取消上下文,在流解码及写出间检查, writer 输出流 返回: int64 已写字节数, error 解码或写入错误,出错时可能已有部分输出

type PageLabelRange

type PageLabelRange struct {
	Start  int64
	Style  Name
	Prefix string
	First  int64
}

PageLabelRange 保存页标签区间的起始索引、编号格式、前缀及起始编号

type Paint

type Paint struct {
	RGB         [3]float64
	CMYK        *[4]float64
	Space       *ColorSpace
	SourceSpace Name
	Process     *ProcessColorants
	Colorant    *ColorantPaint
	Values      [4]float64
	Alpha       float64
	None        bool
	Axial       *AxialGradient
	Radial      *RadialGradient
	Function    *FunctionGradient
	Mesh        *MeshGradient
	Tiling      *TilingPattern
	Shading     *ShadingPattern
}

Paint 保存颜色及不透明度,CMYK保留设备四色,Space与Values保留ICC源分量 None表示丢弃着色输出,与零透明度不同,不参与挖空合成 Process保留原生过程通道,区分未指定通道和已指定的零分量 Colorant保留专色定义和源浓度快照,不随后续图形状态变化 ColorantDevice访问器可接收备用色为None但原生色料可用的画刷,None仅描述其备用显示 SourceSpace保留普通颜色的来源空间族,图案基色使用底层空间族,不以转换后的Space或CMYK代替 Shading保留着色图案的内部状态,Alpha仍属于使用图案的对象

type Path

type Path struct {
	Segments []Segment
	EvenOdd  bool
	Text     []*TextClip
}

Path 保存路径及填充规则

type PathMark

type PathMark struct {
	Sequence     *ContentSequence
	Path         Path
	Style        Style
	Fill, Stroke bool
	StrokeMatrix Matrix
}

PathMark 表示一次路径绘制,路径及裁剪坐标始终位于页面用户空间 StrokeMatrix非零时保留非等比描边变换,线宽及虚线参数属于其逆变换后的坐标空间

type Point

type Point struct{ X, Y float64 }

Point 表示用户空间坐标

type PopupAnnotation

type PopupAnnotation struct {
	Annotation
	Parent Reference
	Open   bool
}

PopupAnnotation 保存弹出批注及其父批注引用,Dictionary中的文字信息已按父批注覆盖

type PostScriptMark

type PostScriptMark struct {
	Data      []byte
	Level1    []byte
	Matrix    Matrix
	Style     Style
	Resources Dictionary
}

PostScriptMark 交付仅用于PostScript输出的原始程序,不执行程序 Data及Level1为独立解码数据,Level1为nil表示未提供低版本程序 Resources属于阅读器,字体按BaseFont名称由输出方处理

type ProcessColorants

type ProcessColorants struct {
	Space    *ColorSpace
	Channels []int
}

ProcessColorants 保存过程空间及源分量对应的过程通道,专色通道为-1,Channels切片只读

func (*ProcessColorants) CMYKMask

func (p *ProcessColorants) CMYKMask() ([4]bool, bool)

CMYKMask 返回可直接在设备四色空间绘制的过程通道 返回: [4]bool 参与绘制的四色通道, bool 是否为未校准设备四色

type ProjectionAnnotation

type ProjectionAnnotation struct {
	Measurement  *ThreeDMeasurement
	ExternalData Dictionary
	Dictionary   Dictionary
}

ProjectionAnnotation 保存依赖运行环境的批注及其可选三维测量关联 Measurement为空不代表无效,其他运行环境可不提供ExData或使用其他子类型

type RadialGradient

type RadialGradient struct {
	Matrix                 Matrix
	Start, End             Point
	StartRadius, EndRadius float64
	Extend                 [2]bool
	Stops                  []GradientStop
	Space                  *ColorSpace
	Intent                 Name
	Background             *[4]float64
	Bounds                 *Rectangle
	// contains filtered or unexported fields
}

RadialGradient 保存双圆径向渐变及两端延伸方式,Matrix将渐变坐标映射到页面 Matrix为零值时使用单位矩阵 Stops仅在函数可精确展开为线性分段时提供,否则通过ValuesAt或ColorAt求值 Background及Bounds仅用于着色图案,Bounds使用渐变坐标

func (*RadialGradient) ColorAt

func (g *RadialGradient) ColorAt(position float64) ([3]float64, error)

ColorAt 在源颜色空间内插值,再按渲染意图转换为sRGB 入参: position 归一化双圆插值位置,范围外使用端点颜色 返回: [3]float64 sRGB颜色, error 无效渐变或颜色变换错误

func (*RadialGradient) ColorantAt

func (g *RadialGradient) ColorantAt(position float64) (*ColorantPaint, error)

ColorantAt 求值径向渐变的源色料浓度,不使用备用空间分量替代源浓度 入参: position 归一化双圆插值位置,范围外使用端点 返回: *ColorantPaint 色料快照,非色料渐变为nil, error 参数或函数错误

func (*RadialGradient) ColorantSpace

func (g *RadialGradient) ColorantSpace() *ColorantSpace

ColorantSpace 返回径向渐变的只读原始色料定义 返回: *ColorantSpace 色料定义,普通颜色空间为nil

func (*RadialGradient) ColorantValuesAt

func (g *RadialGradient) ColorantValuesAt(position float64, out []float64) error

ColorantValuesAt 将径向渐变的原始浓度写入调用方缓冲 入参: position 归一化双圆插值位置, out 与色料数等长的输出缓冲 返回: error 非色料渐变、参数或函数错误,错误时不保证缓冲内容

func (*RadialGradient) PreparePosition

func (g *RadialGradient) PreparePosition() (GradientPosition, error)

PreparePosition 准备双圆参数求值,复用页面到渐变坐标的逆矩阵 返回: GradientPosition 只读几何, error 非法半径或矩阵

func (*RadialGradient) ValuesAt

func (g *RadialGradient) ValuesAt(position float64) ([4]float64, error)

ValuesAt 按原始函数计算径向渐变的源颜色分量 入参: position 归一化双圆插值位置,范围外使用端点 返回: [4]float64 源空间分量, error 无效求值

type ReadError

type ReadError struct {
	Offset int64
	Err    error
}

ReadError 表示输入源读取失败,Err保留原始错误

func (*ReadError) Error

func (e *ReadError) Error() string

Error 返回读取位置及原始错误 返回: string 错误描述

func (*ReadError) Unwrap

func (e *ReadError) Unwrap() error

Unwrap 返回原始读取错误 返回: error 原始错误

type Reader

type Reader struct {
	Version string
	Trailer Dictionary
	// contains filtered or unexported fields
}

Reader 读取PDF对象,方法不可并发调用,返回对象不可并发修改

func NewReader

func NewReader(source io.ReaderAt, size int64) (*Reader, error)

NewReader 从随机读取器读取PDF,源读取器仍由调用方管理 按交叉引用读取对象,源读取器须在使用期间保持可读 入参: source 随机读取器, size 文件字节数 返回: *Reader 阅读器, error 错误信息

func NewReaderWithOptions

func NewReaderWithOptions(source io.ReaderAt, size int64, options ReaderOptions) (*Reader, error)

NewReaderWithOptions 按读取选项打开PDF,源读取器仍由调用方管理 入参: source 随机读取器, size 文件字节数, options 读取及外观选项 返回: *Reader 阅读器, error 错误信息

func NewReaderWithPassword

func NewReaderWithPassword(source io.ReaderAt, size int64, password []byte) (*Reader, error)

NewReaderWithPassword 使用密码读取PDF,源读取器仍由调用方管理 支持RC4、AES-128和AES-256;R2至R4使用PDFDocEncoding,R5/R6使用经SASLprep处理的UTF-8 入参: source 随机读取器, size 文件字节数, password 用户或所有者密码 返回: *Reader 阅读器, error 错误信息

func NewReaderWithUTF8Password

func NewReaderWithUTF8Password(source io.ReaderAt, size int64, password []byte) (*Reader, error)

NewReaderWithUTF8Password 自动按安全处理器版本转换UTF-8密码并读取PDF 入参: source 随机读取器, size 文件字节数, password 用户或所有者密码的UTF-8字节 返回: *Reader 阅读器, error 错误信息

func Open

func Open(path string) (*Reader, error)

Open 打开PDF文件并读取交叉引用 入参: path 文件路径 返回: *Reader 阅读器, error 错误信息

func OpenWithPassword

func OpenWithPassword(path string, password []byte) (*Reader, error)

OpenWithPassword 使用已编码密码打开PDF,编码规则见NewReaderWithPassword 入参: path 文件路径, password 用户或所有者密码,nil表示空密码 返回: *Reader 阅读器, error 错误信息

func (*Reader) BaseURI

func (r *Reader) BaseURI() (string, error)

BaseURI 读取文档声明的链接基准地址,不访问外部资源 返回: string 基准地址,未声明时为空, error 错误信息

func (*Reader) Close

func (r *Reader) Close() error

Close 释放源数据、对象缓存和解密密钥,关闭Open持有的文件 不关闭NewReader的外部数据源;关闭后不可继续读取,重复关闭不产生错误 返回: error 关闭错误

func (*Reader) ColorantTransfer

func (r *Reader) ColorantTransfer(fallback *TransferFunction, halftone *Halftone, colorant Name) (*TransferFunction, error)

ColorantTransfer 选择原生色料的传递函数,非主色使用灰度回退 分量按加色形式求值,专色浓度在求值前后取补值 入参: fallback 图形状态函数, halftone 网屏定义, colorant 原生分量名称 返回: *TransferFunction 各通道相同的独立函数,空值为恒等, error 分量或函数错误

func (*Reader) CompileHalftone

func (r *Reader) CompileHalftone(ctx context.Context, h *Halftone, options HalftoneOptions) (*HalftoneScreen, error)

CompileHalftone 编译类型1、5、6、10和16网屏,名称优先匹配设备定义 入参: ctx 取消上下文, h 网屏定义, options 设备参数,默认单比特及百万像素网屏上限 返回: *HalftoneScreen 设备网屏,默认网屏返回空值, error 参数或函数错误

func (*Reader) CreateImage

func (r *Reader) CreateImage(ctx context.Context, source image.Image, options ...ImageWriteOptions) (*Image, error)

CreateImage 从像素创建独立PDF图像及软遮罩,不修改文档或分配间接对象编号 入参: ctx 取消上下文, source 像素图像, options 可选编码参数,至多一项 返回: *Image 图像描述及独立编码数据, error 参数、编码或关闭错误

func (*Reader) DeviceTransfer

func (r *Reader) DeviceTransfer(fallback *TransferFunction, halftone *Halftone, model Name) (*TransferFunction, error)

DeviceTransfer 合并原生设备通道的网屏传递函数,网屏定义优先于图形状态 入参: fallback 图形状态函数, halftone 网屏定义, model 原生设备颜色空间 返回: *TransferFunction 有效函数, error 通道或函数错误

func (*Reader) Encryption

func (r *Reader) Encryption() *EncryptionInfo

Encryption 返回加密信息副本,未加密文档返回nil 返回: *EncryptionInfo 加密信息

func (*Reader) Info

func (r *Reader) Info() (DocumentInfo, error)

Info 读取文档信息字典,解码PDF文本字符串,日期保留原文以免丢失精度 配置Warning时诊断无效辅助字段并读取其他文本,原始对象保持不变 返回: DocumentInfo 文档信息, error 字典或字段类型错误

func (*Reader) Metadata

func (r *Reader) Metadata() (*Stream, error)

Metadata 读取文档目录声明的元数据流,不解码XML或与信息字典合并 返回: *Stream 元数据流,未声明时为空, error 引用或定义错误

func (*Reader) Object

func (r *Reader) Object(ref Reference) (Object, error)

Object 按编号与代数读取间接对象 不存在或已释放的引用按PDF规则返回空对象 入参: ref 间接引用 返回: Object 对象, error 错误信息

func (*Reader) OptimizeTo

func (r *Reader) OptimizeTo(ctx context.Context, writer io.Writer, options OptimizeOptions) (report OptimizeReport, err error)

OptimizeTo 重写PDF对象及资源,保留未知字典、表单、附件、导航和加密配置 无损模式只改变表示与压缩;有损模式可重新编码可安全识别的RGB或灰度图片 签名文件原样交付,不修改签名;出错时应丢弃本次输出,Reader须保持源数据可读 入参: ctx 取消上下文, writer 输出流, options 优化配置 返回: OptimizeReport 优化结果, error 读写错误

func (*Reader) OptionalContentVisible

func (r *Reader) OptionalContentVisible(object Object) (bool, error)

OptionalContentVisible 按文档默认配置判断可选内容的可见性,供固定版式输出使用 不应用交互阅读器的Usage自动状态;交互状态可通过Visitor.OptionalContent提供 入参: object OCG引用或OCMD字典 返回: bool 是否可见, error 配置或表达式错误

func (*Reader) OutputIntents

func (r *Reader) OutputIntents() ([]OutputIntent, error)

OutputIntents 读取并验证文档输出意图,不将目标配置应用到普通屏显 配置Warning时诊断无效辅助字段并返回可读取的部分,无效配置的Space为空,原始对象保持不变 返回: []OutputIntent 按文档顺序排列的输出条件, error 字典、字段或ICC错误

func (*Reader) ReadAnnotationAppearance

func (r *Reader) ReadAnnotationAppearance(annotation Annotation) (*Stream, error)

ReadAnnotationAppearance 读取已有的正常外观,按AS选择状态,不生成或解码外观 入参: annotation 注解 返回: *Stream 表单外观,未提供或状态不存在时为空, error 类型或引用错误

func (*Reader) ReadAnnotationBackground

func (r *Reader) ReadAnnotationBackground(annotation Annotation) (*[3]float64, error)

ReadAnnotationBackground 按PDF标准表189读取外观特征中的背景色,空值表示透明 入参: annotation 注解,仅读取MK中的BG,不分析外观流 返回: *[3]float64 设备RGB背景色, error 字典、颜色或引用错误

func (*Reader) ReadAnnotationFlags

func (r *Reader) ReadAnnotationFlags(annotation Annotation) (int64, error)

ReadAnnotationFlags 读取非负注解标志,未提供或空值按零处理 入参: annotation 注解信息 返回: int64 标志位, error 类型或引用错误

func (*Reader) ReadAnnotationText

func (r *Reader) ReadAnnotationText(annotation Annotation, field Name, warning func(Diagnostic)) (string, error)

ReadAnnotationText 读取注解文本字段,RC和RV允许文本流,其他字段要求文本字符串 入参: annotation 注解, field 文本字段名, warning 异常字段警告,空值使用严格检查 返回: string Unicode文本, error 引用、类型或编码错误

func (*Reader) ReadAnnotationTextContext

func (r *Reader) ReadAnnotationTextContext(ctx context.Context, annotation Annotation, field Name, warning func(Diagnostic)) (string, error)

ReadAnnotationTextContext 读取注解文本并响应取消,取消错误不作为异常字段忽略 入参: ctx 取消上下文, annotation 注解, field 文本字段名, warning 异常字段警告,空值使用严格检查 返回: string Unicode文本, error 引用、类型、编码或取消错误

func (*Reader) ReadAnnotationTriggers

func (r *Reader) ReadAnnotationTriggers(ctx context.Context, annotation Annotation) ([]ActionTrigger, error)

ReadAnnotationTriggers 读取注解生效事件,主动作优先于U,焦点事件仅适用于Widget 未知事件不激活;返回字典为只读视图,动作链可交给WalkActions遍历 入参: ctx 取消上下文, annotation 注解 返回: []ActionTrigger 按标准表顺序排列的事件, error 字典、引用或取消错误

func (*Reader) ReadChoiceField

func (r *Reader) ReadChoiceField(annotation Annotation) (ChoiceField, error)

ReadChoiceField 读取选择字段,区分显示文字和导出值,不执行交互动作 入参: annotation 字段控件 返回: ChoiceField 选择状态, error 字段或选项错误

func (*Reader) ReadColorFunction

func (r *Reader) ReadColorFunction(object Object) (*ColorFunction, error)

ReadColorFunction 解析类型0、2、3及4的单分量颜色函数,不截断负输出 入参: object 函数字典或数据流 返回: *ColorFunction 已解析函数, error 引用或函数错误

func (*Reader) ReadColorantSpace

func (r *Reader) ReadColorantSpace(object Object, resources Dictionary) (*ColorantSpace, error)

ReadColorantSpace 读取分色、多色或索引基础空间,解析资源别名及实际选用的默认备用色 入参: object 源颜色空间, resources 当前资源字典 返回: *ColorantSpace 只读色料定义,普通设备色为nil, error 定义错误

func (*Reader) ReadDestination

func (r *Reader) ReadDestination(object Object) (Destination, error)

ReadDestination 解析直接目标或名称树中的命名目标,不跳转页面 入参: object 目标数组、名称、字符串或引用 返回: Destination 跳转目标, error 错误信息

func (*Reader) ReadDocumentTriggers

func (r *Reader) ReadDocumentTriggers(ctx context.Context) ([]ActionTrigger, error)

ReadDocumentTriggers 读取文档关闭、保存和打印事件,标准要求起始动作为JavaScript 入参: ctx 取消上下文 返回: []ActionTrigger 附加动作, error 类型、引用或取消错误

func (*Reader) ReadEmbeddedTargetFile

func (r *Reader) ReadEmbeddedTargetFile(ctx context.Context, target EmbeddedTarget) (FileSpecification, error)

ReadEmbeddedTargetFile 定位当前文档中的子文件,不解码内容,不推测父文档 入参: ctx 取消上下文, target 子文件路径的一步 返回: FileSpecification 内嵌文件说明, error 路径、目标缺失或结构错误

func (*Reader) ReadExternalGoToAction

func (r *Reader) ReadExternalGoToAction(ctx context.Context, object Object) (ExternalGoToAction, error)

ReadExternalGoToAction 解析单个跨文件或嵌入文件跳转,检测目标路径循环 入参: ctx 取消上下文, object 动作字典或间接引用 返回: ExternalGoToAction 目标信息, error 类型、必填项目或路径错误

func (*Reader) ReadField

func (r *Reader) ReadField(annotation Annotation) (Dictionary, error)

ReadField 读取控件字段并补齐可继承属性,不修改原始注解字典 入参: annotation 表单控件 返回: Dictionary 字段属性, error 字段或继承链错误

func (*Reader) ReadFileData

func (r *Reader) ReadFileData(ctx context.Context, file FileSpecification, resolver FileResolver) ([]byte, error)

ReadFileData 读取内嵌文件或交给调用方解析外部文件,不改变文件编码 入参: ctx 取消上下文, file 文件说明, resolver 外部文件读取器,可为空 返回: []byte 文件数据, error 解码、取消或外部文件不可用

func (*Reader) ReadFileSpecification

func (r *Reader) ReadFileSpecification(object Object) (FileSpecification, error)

ReadFileSpecification 解析文件名、说明和可选的内嵌数据流,优先使用Unicode文件名 入参: object 文件说明字典、字符串或间接引用 返回: FileSpecification 文件说明, error 结构或文本编码错误

func (*Reader) ReadFont

func (r *Reader) ReadFont(object Object) (*Font, error)

ReadFont 读取字体资源及嵌入程序 入参: object 字体字典或引用 返回: *Font 字体资源, error 错误信息

func (*Reader) ReadFontContext

func (r *Reader) ReadFontContext(ctx context.Context, object Object) (*Font, error)

ReadFontContext 读取字体及映射,解码和度量展开使用本次取消上下文 入参: ctx 取消上下文, object 字体字典或引用 返回: *Font 完整字体资源, error 读取或取消错误

func (*Reader) ReadHalftone

func (r *Reader) ReadHalftone(object Object) (*Halftone, error)

ReadHalftone 读取类型1、5、6、10和16的网屏定义,Default返回空值 入参: object 半色调字典、数据流、Default或间接引用 返回: *Halftone 网屏参数, error 类型、尺寸或阈值数据错误

func (*Reader) ReadHalftoneForDevice

func (r *Reader) ReadHalftoneForDevice(object Object, named map[string]*Halftone) (*Halftone, error)

ReadHalftoneForDevice 优先选择设备命名网屏,未匹配时解析文件中的备用定义 入参: object 网屏对象, named 只读设备网屏,匹配后不解析其他字段或阈值流 返回: *Halftone 有效网屏, error 名称或备用定义错误

func (*Reader) ReadHideAction

func (r *Reader) ReadHideAction(ctx context.Context, object Object) (HideAction, error)

ReadHideAction 按PDF标准表210解析注解及字段的隐藏或显示目标 入参: ctx 取消上下文, object 动作字典或引用 返回: HideAction 目标和可见性操作, error 目标、标志或取消错误

func (*Reader) ReadImage

func (r *Reader) ReadImage(object Object) (*Image, error)

ReadImage 读取图像XObject描述,按标准选择生效属性,不隐式转换颜色 入参: object 图像对象或引用 返回: *Image 图像描述, error 错误信息

func (*Reader) ReadImageWithResources

func (r *Reader) ReadImageWithResources(object Object, resources Dictionary) (*Image, error)

ReadImageWithResources 读取图像并按当前资源解析颜色空间及默认设备色 入参: object 图像对象或引用, resources 当前资源字典 返回: *Image 图像描述, error 图像或颜色空间错误

func (*Reader) ReadImportDataAction

func (r *Reader) ReadImportDataAction(ctx context.Context, object Object) (ImportDataAction, error)

ReadImportDataAction 按PDF标准表240解析FDF文件说明,不访问外部文件 入参: ctx 取消上下文, object 动作字典或引用 返回: ImportDataAction 文件信息, error 字典、文件说明或取消错误

func (*Reader) ReadJavaScriptAction

func (r *Reader) ReadJavaScriptAction(ctx context.Context, object Object) (JavaScriptAction, error)

ReadJavaScriptAction 按PDF标准表217读取文本串或文本流中的脚本 入参: ctx 取消上下文, object 动作字典或引用 返回: JavaScriptAction 脚本文字, error 字典、编码、流解码或取消错误

func (*Reader) ReadLaunchAction

func (r *Reader) ReadLaunchAction(ctx context.Context, object Object) (LaunchAction, error)

ReadLaunchAction 按PDF标准表203和表204解析启动动作及平台参数 入参: ctx 取消上下文, object 动作字典或引用 返回: LaunchAction 启动信息, error 结构、参数或取消错误

func (*Reader) ReadMediaClip

func (r *Reader) ReadMediaClip(ctx context.Context, object Object) (*MediaClip, error)

ReadMediaClip 读取媒体数据或连续片段,不访问外部文件或网络 入参: ctx 取消上下文, object 媒体片段字典或间接引用 返回: *MediaClip 媒体片段, error 定义或循环引用错误

func (*Reader) ReadMetadata

func (r *Reader) ReadMetadata(object Object) (*Stream, error)

ReadMetadata 读取元数据流或其引用,可用于组件及标记内容的Metadata字段 返回流沿用所属阅读器的生命周期,通过DecodeContext按需解码,不修改原始XML 入参: object 元数据流或引用,空值表示未声明 返回: *Stream 元数据流, error 引用、类型或子类型错误

func (*Reader) ReadMovie

func (r *Reader) ReadMovie(object Object) (Movie, error)

ReadMovie 读取视频字典,未声明尺寸时保留零值 入参: object 视频字典或间接引用 返回: Movie 视频信息, error 字典或显示参数错误

func (*Reader) ReadMovieAction

func (r *Reader) ReadMovieAction(ctx context.Context, object Object) (MovieAction, error)

ReadMovieAction 按PDF标准表209解析视频引用、标题及播放操作 入参: ctx 取消上下文, object 动作字典或引用 返回: MovieAction 播放动作, error 目标、操作、播放参数或取消错误

func (*Reader) ReadMovieActivation

func (r *Reader) ReadMovieActivation(ctx context.Context, object Object) (MovieActivation, error)

ReadMovieActivation 按PDF标准表296解析播放区间、时间单位及窗口参数 入参: ctx 取消上下文, object 播放字典或引用,空值采用标准默认值 返回: MovieActivation 播放参数, error 数值、窗口、引用或取消错误

func (*Reader) ReadMoviePlayback

func (r *Reader) ReadMoviePlayback(ctx context.Context, page *Page, object Object) (MoviePlayback, error)

ReadMoviePlayback 在指定页面内解析视频动作目标,以显式动作参数覆盖注解播放参数 page应为执行动作时的页面;库不执行前序跳转,也不在其他页面猜测同名目标 入参: ctx 取消上下文, page 当前页面, object 视频动作字典或引用 返回: MoviePlayback 视频播放信息, error 目标、参数、引用或取消错误

func (*Reader) ReadOpenAction

func (r *Reader) ReadOpenAction(ctx context.Context) (OpenAction, error)

ReadOpenAction 读取文档初始目标或打开动作,不跳转页面或执行动作 入参: ctx 取消上下文 返回: OpenAction 打开行为, error 类型、目标或取消错误

func (*Reader) ReadPageTriggers

func (r *Reader) ReadPageTriggers(ctx context.Context, page *Page) ([]ActionTrigger, error)

ReadPageTriggers 读取页面打开和关闭动作,不从父级页树继承AA 入参: ctx 取消上下文, page 页面 返回: []ActionTrigger 附加动作, error 类型、引用或取消错误

func (*Reader) ReadPopupAnnotation

func (r *Reader) ReadPopupAnnotation(object Object) (PopupAnnotation, error)

ReadPopupAnnotation 读取弹出批注,继承父批注的Contents、M、C和T,不执行界面操作 入参: object 弹出批注字典或间接引用 返回: PopupAnnotation 弹出批注信息, error 解析错误

func (*Reader) ReadProjectionAnnotation

func (r *Reader) ReadProjectionAnnotation(annotation Annotation) (ProjectionAnnotation, error)

ReadProjectionAnnotation 解析投影批注,不要求静态外观或递归展开测量的回指 入参: annotation 投影批注 返回: ProjectionAnnotation 关联数据, error 类型、参数或引用错误

func (*Reader) ReadRedaction

func (r *Reader) ReadRedaction(ctx context.Context, annotation Annotation) (Redaction, error)

ReadRedaction 读取删改注解的区域及覆盖属性,不执行内容移除或覆盖绘制 入参: ctx 取消上下文, annotation 删改注解 返回: Redaction 删改信息, error 类型、区域或覆盖属性错误

func (*Reader) ReadRedactionRegions

func (r *Reader) ReadRedactionRegions(ctx context.Context, annotation Annotation) ([][4]Point, error)

ReadRedactionRegions 读取删改区域,QuadPoints优先于Rect,保留空数组所表示的空区域 入参: ctx 取消上下文, annotation 删改注解 返回: [][4]Point 逆时针四边形, error 类型或几何错误

func (*Reader) ReadReferenceXObject

func (r *Reader) ReadReferenceXObject(object Object) (ReferenceXObject, error)

ReadReferenceXObject 读取引用表单的Ref字典,不访问目标文件 入参: object 引用字典或间接引用 返回: ReferenceXObject 目标说明, error 字典或选择参数错误

func (*Reader) ReadRemoteDestination

func (r *Reader) ReadRemoteDestination(object Object) (RemoteDestination, error)

ReadRemoteDestination 读取远程目标,不查找源文档名称树,不解释页对象引用 入参: object 名称、字节串或显式目标数组 返回: RemoteDestination 目标信息, error 页码、模式或参数错误

func (*Reader) ReadRendition

func (r *Reader) ReadRendition(ctx context.Context, object Object) (*Rendition, error)

ReadRendition 读取媒体呈现及选择器候选树,保留必须遵守与尽力处理的约束 入参: ctx 取消上下文, object 呈现字典或间接引用 返回: *Rendition 媒体呈现, error 定义或循环引用错误

func (*Reader) ReadRenditionPlayback

func (r *Reader) ReadRenditionPlayback(ctx context.Context, object Object) (RenditionPlayback, error)

ReadRenditionPlayback 按PDF表214读取媒体动作,校验屏幕在所属页注解数组中的引用 入参: ctx 取消上下文, object 动作字典或引用 返回: RenditionPlayback 媒体动作, error 参数、目标、资源或取消错误

func (*Reader) ReadResetFormAction

func (r *Reader) ReadResetFormAction(ctx context.Context, object Object) (ResetFormAction, error)

ReadResetFormAction 按PDF标准表238和表239解析重置范围及排除标志 入参: ctx 取消上下文, object 动作字典或引用 返回: ResetFormAction 重置范围, error 字段、标志、引用或取消错误

func (*Reader) ReadRichMedia

func (r *Reader) ReadRichMedia(ctx context.Context, annotation Annotation) (RichMedia, error)

ReadRichMedia 解析资源名称树和实例配置,允许实例资源不出现在名称树中 入参: ctx 取消上下文, annotation 富媒体注解 返回: RichMedia 媒体信息, error 资源、配置或引用错误

func (*Reader) ReadSound

func (r *Reader) ReadSound(object Object) (Sound, error)

ReadSound 读取音频对象,原始多字节样本采用大端顺序 入参: object 音频流或间接引用 返回: Sound 音频参数, error 无效对象或参数

func (*Reader) ReadSoundAction

func (r *Reader) ReadSoundAction(ctx context.Context, object Object) (SoundAction, error)

ReadSoundAction 解析标准音频动作,保留原始音频对象及外部文件说明 入参: ctx 取消上下文, object 动作字典或间接引用 返回: SoundAction 音频动作, error 类型、必填字段或播放参数错误

func (*Reader) ReadSpotFunction

func (r *Reader) ReadSpotFunction(object Object) (*SpotFunction, error)

ReadSpotFunction 读取标准预定义名称、类型0采样或类型4计算器网点函数 入参: object 网点函数名称、数据流或间接引用 返回: *SpotFunction 网点函数, error 定义错误

func (*Reader) ReadThreeD

func (r *Reader) ReadThreeD(annotation Annotation) (ThreeD, error)

ReadThreeD 解析3D注解及共享数据引用,保留模型原始编码和视图选择 入参: annotation 3D注解 返回: ThreeD 模型信息, error 类型、引用或视图错误

func (*Reader) ReadThreeDActivation

func (r *Reader) ReadThreeDActivation(object Object) (ThreeDActivation, error)

ReadThreeDActivation 按PDF标准表299解析3D激活参数,空值采用标准默认值 入参: object 激活字典或引用 返回: ThreeDActivation 激活参数, error 字段类型、枚举或引用错误

func (*Reader) ReadThreeDAnimation

func (r *Reader) ReadThreeDAnimation(object Object) (ThreeDAnimation, error)

ReadThreeDAnimation 按PDF标准表301解析动画方式,未知方式按None处理并忽略播放参数 入参: object 动画字典或引用 返回: ThreeDAnimation 动画参数, error 字典、数值或引用错误

func (*Reader) ReadThreeDBackground

func (r *Reader) ReadThreeDBackground(object Object) (ThreeDBackground, error)

ReadThreeDBackground 按PDF标准表306解析背景,缺省使用白色且仅覆盖3D视口 入参: object 背景字典或引用 返回: ThreeDBackground 背景参数, error 类型、数值或引用错误

func (*Reader) ReadThreeDCamera

func (r *Reader) ReadThreeDCamera(object Object) (ThreeDCamera, error)

ReadThreeDCamera 按PDF标准表304解析相机来源,仅读取该来源生效的参数 入参: object 视图字典或引用 返回: ThreeDCamera 相机参数, error 类型、数值、路径或引用错误

func (*Reader) ReadThreeDContext

func (r *Reader) ReadThreeDContext(ctx context.Context, annotation Annotation) (ThreeD, error)

ReadThreeDContext 解析三维注解及默认视图,支持批量测量读取取消 入参: ctx 取消上下文, annotation 三维注解 返回: ThreeD 模型信息, error 类型、引用、视图或取消错误

func (*Reader) ReadThreeDCrossSection

func (r *Reader) ReadThreeDCrossSection(object Object) (ThreeDCrossSection, error)

ReadThreeDCrossSection 按PDF标准表311读取剖切参数,不执行三维绘制 入参: object 剖切字典或引用 返回: ThreeDCrossSection 剖切参数, error 类型、方向、数值或引用错误

func (*Reader) ReadThreeDLighting

func (r *Reader) ReadThreeDLighting(object Object) (ThreeDLighting, error)

ReadThreeDLighting 按PDF标准表309及表310解析灯光,未知方案忽略并沿用模型灯光 入参: object 灯光字典或引用 返回: ThreeDLighting 灯光参数, error 类型或引用错误

func (*Reader) ReadThreeDMarkups

func (r *Reader) ReadThreeDMarkups(ctx context.Context, annotations []Annotation) ([]*ThreeDMarkup, error)

ReadThreeDMarkups 批量解析同页批注关联,按输入顺序返回,未关联项为空 没有三维批注时返回空列表;名称引用仅在传入的同页注解中查找 入参: ctx 取消上下文, annotations 同页注解 返回: []*ThreeDMarkup 批注关联, error 类型、引用或取消错误

func (*Reader) ReadThreeDMeasurement

func (r *Reader) ReadThreeDMeasurement(object Object) (ThreeDMeasurement, error)

ReadThreeDMeasurement 按PDF标准表326至331解析五类三维测量和批注 入参: object 测量字典或引用 返回: ThreeDMeasurement 测量参数, error 类型、参数或引用错误

func (*Reader) ReadThreeDMeasurements

func (r *Reader) ReadThreeDMeasurements(ctx context.Context, object Object) ([]ThreeDMeasurement, error)

ReadThreeDMeasurements 读取视图的MA数组,取消或解析失败时不返回部分结果 入参: ctx 取消上下文, object 测量数组或引用,可为空 返回: []ThreeDMeasurement 测量数据, error 类型、参数或取消错误

func (*Reader) ReadThreeDNode

func (r *Reader) ReadThreeDNode(object Object) (ThreeDNode, error)

ReadThreeDNode 按PDF标准表312读取三维节点,不修改原始字典 入参: object 节点字典或引用 返回: ThreeDNode 节点参数, error 类型、数值或引用错误

func (*Reader) ReadThreeDPresentation

func (r *Reader) ReadThreeDPresentation(object Object) (ThreeDPresentation, error)

ReadThreeDPresentation 按PDF标准表304及表308读取生效的视图内容,不执行脚本 入参: object 视图字典或引用 返回: ThreeDPresentation 呈现参数, error 类型或引用错误

func (*Reader) ReadThreeDProjection

func (r *Reader) ReadThreeDProjection(object Object) (ThreeDProjection, error)

ReadThreeDProjection 按PDF标准表305解析投影,仅校验当前投影与裁剪方式生效的字段 入参: object 投影字典或引用,空值使用90度透视投影 返回: ThreeDProjection 投影参数, error 类型、数值或引用错误

func (*Reader) ReadThreeDRenderMode

func (r *Reader) ReadThreeDRenderMode(object Object) (*ThreeDRenderMode, error)

ReadThreeDRenderMode 按PDF标准表307及表308读取绘制模式,仅解析生效字段 入参: object 绘制字典或引用,空值及未知模式忽略 返回: *ThreeDRenderMode 绘制参数, error 类型、数值或引用错误

func (*Reader) ReadThreeDViewBox

func (r *Reader) ReadThreeDViewBox(annotation Annotation) (Rectangle, error)

ReadThreeDViewBox 按PDF标准表298解析以注解中心为原点的显示区域,不使用页面坐标 入参: annotation 3D注解 返回: Rectangle 显示区域, error 类型、范围或引用错误

func (*Reader) ReadTransferFunction

func (r *Reader) ReadTransferFunction(object Object) (*TransferFunction, error)

ReadTransferFunction 解析单函数或四通道数组,恒等函数返回空值 入参: object 传递函数定义或Identity 返回: *TransferFunction 已解析函数, error 引用或函数错误

func (*Reader) ReferenceIDMatches

func (r *Reader) ReferenceIDMatches(reference ReferenceXObject) (bool, error)

ReferenceIDMatches 比较引用记录与目标文档的文件标识,不阻止读取已变化的文件 入参: reference 引用目标 返回: bool 文件标识相同或引用未声明标识, error 标识结构错误

func (*Reader) ReplaceImagesTo

func (r *Reader) ReplaceImagesTo(ctx context.Context, writer io.Writer, images map[Reference]image.Image, options ...ImageWriteOptions) (OptimizeReport, error)

ReplaceImagesTo 无损替换间接图像,保留页面布局、其他对象及原加密配置 默认保留非预乘颜色和透明度的八位或十六位精度;不修改源对象,不替换遮罩图像或签名文档 出错时应丢弃本次输出,Reader及图片须在调用期间保持可读 入参: ctx 取消上下文, writer 输出流, images 图像引用与替换像素, options 可选替换参数,至多一项 返回: OptimizeReport 写出结果, error 参数、编码或写入错误

func (*Reader) Resolve

func (r *Reader) Resolve(object Object) (Object, error)

Resolve 解析间接引用,直接对象原样返回 入参: object 待解析对象 返回: Object 解析后的对象, error 错误信息

func (*Reader) ResolveReferencePage

func (r *Reader) ResolveReferencePage(ctx context.Context, reference ReferenceXObject) (*Page, error)

ResolveReferencePage 在目标文档中按索引或页标签查找引用页面 入参: ctx 取消上下文, reference 引用目标 返回: *Page 目标页面, error 页面缺失或标签结构错误

func (*Reader) ResolveRemoteDestination

func (r *Reader) ResolveRemoteDestination(ctx context.Context, remote RemoteDestination) (Destination, error)

ResolveRemoteDestination 在目标阅读器中解析远程目标并检查页面归属 入参: ctx 取消上下文, remote 已解析的远程目标 返回: Destination 当前文档目标, error 命名目标、越界或页面树错误

func (*Reader) ResolveStructureRole

func (r *Reader) ResolveStructureRole(ctx context.Context, tag Name, accepts func(Name) bool) (Name, bool, error)

ResolveStructureRole 沿角色映射查找调用方支持的角色,循环映射在重复名称处结束 已声明映射时先映射再识别,未匹配时仍可从结构元素保留原始标签 入参: ctx 取消上下文, tag 原始角色, accepts 支持的角色判断函数 返回: Name 匹配角色, bool 是否匹配, error 解析、类型或取消错误

func (*Reader) RewriteTo

func (r *Reader) RewriteTo(ctx context.Context, writer io.Writer, options RewriteOptions) (OptimizeReport, error)

RewriteTo 一次写出图像、文字、链接、附件及事件修改,保留外观和未知属性 指定目标时替换原主动作;已有GoTo动作保留后续动作,其他动作整体替换 独占链接保留原引用;共享链接按页面复制,带结构标记的共享链接不能单独拆分 修改大纲时按实际层级修正父节点引用,不改变节点顺序及显示样式 不修改签名文件;出错时应丢弃本次输出,调用期间源数据和替换图像须保持可读 入参: ctx 取消上下文, writer 输出流, options 替换配置 返回: OptimizeReport 写出结果, error 参数、编码或写入错误

func (*Reader) StructureAttributes

func (r *Reader) StructureAttributes(ctx context.Context, item StructureItem) ([]StructureAttribute, error)

StructureAttributes 展开结构元素的属性类和直接属性,类属性在前,直接属性在后 同名属性以直接声明为准,修订号不匹配的属性仍保留,不修改共享属性对象 入参: ctx 取消上下文, item 结构元素 返回: []StructureAttribute 属性列表, error 解析、结构或取消错误

func (*Reader) StructureContent

func (r *Reader) StructureContent(item StructureItem) (StructureContent, error)

StructureContent 解析MCR或OBJR的内容容器及父树键,不展开父树或解码流 入参: item 内容引用 返回: StructureContent 内容容器, error 引用或父树键错误

func (*Reader) StructureTree

func (r *Reader) StructureTree() (*StructureTree, error)

StructureTree 读取逻辑结构入口,不展开属性类或改写角色映射 返回: *StructureTree 结构入口,未声明时为空, error 解析或类型错误

func (*Reader) WalkActions

func (r *Reader) WalkActions(ctx context.Context, object Object, visit func(ActionInfo) error) error

WalkActions 按动作及Next顺序遍历动作链,允许不同分支共享动作 入参: ctx 取消上下文, object 起始动作, visit 动作访问器 返回: error 类型、循环引用或访问器错误

func (*Reader) WalkAnnotationAppearance

func (r *Reader) WalkAnnotationAppearance(ctx context.Context, page *Page, annotation Annotation, visitor Visitor) error

WalkAnnotationAppearance 解释注解当前外观并映射到页面用户空间 Warning非空时按控件属性恢复结构无效的外观,保留原始字典并报告原因 入参: ctx 取消上下文, page 所在页面, annotation 注解, visitor 图元访问器 返回: error 外观缺失、解析或访问错误

func (*Reader) WalkEmbeddedFiles

func (r *Reader) WalkEmbeddedFiles(ctx context.Context, visit func(string, FileSpecification) error) error

WalkEmbeddedFiles 枚举文档名称树中的附件,不解码数据、不读取外部文件 入参: ctx 取消上下文, visit 名称树原始键和文件说明的访问函数 返回: error 名称树、文件说明或访问错误

func (*Reader) WalkNameTree

func (r *Reader) WalkNameTree(ctx context.Context, root Object, visit func(string, Object) error) error

WalkNameTree 按节点顺序访问名称树,名称保留原始字节,值不预先解析 配置Warning时诊断直接子字典、重复键及重复节点,重复节点仅访问一次 入参: ctx 取消上下文, root 名称树根, visit 名称和值的访问函数 返回: error 结构、重复名称、循环或访问错误

func (*Reader) WalkNumberTree

func (r *Reader) WalkNumberTree(ctx context.Context, root Object, visit func(int64, Object) error) error

WalkNumberTree 按节点顺序访问数字树并验证键递增,值不预先解析 配置Warning时诊断直接子字典、键顺序和Limits错误,保留访问顺序及所有键值 入参: ctx 取消上下文, root 数字树根, visit 数字键和值的访问函数 返回: error 结构、重复键、循环或访问错误

func (*Reader) WalkOutlines

func (r *Reader) WalkOutlines(ctx context.Context, visit func(int, OutlineItem) error) error

WalkOutlines 按先序访问文档目录,包括折叠节点的子项,不限制层级 入参: ctx 取消上下文, visit 零基层级和目录项的访问函数 返回: error 目录结构、文本、循环或访问错误

func (*Reader) WalkPage

func (r *Reader) WalkPage(ctx context.Context, page *Page, visitor Visitor) error

WalkPage 解释页面内容并按绘制顺序访问可准确表达的图元,注解由Page.Annotations读取 入参: ctx 取消上下文, page 页面, visitor 图元访问器 返回: error 错误信息

func (*Reader) WalkPageLabelRanges

func (r *Reader) WalkPageLabelRanges(ctx context.Context, visit func(PageLabelRange) error) error

WalkPageLabelRanges 按起始页面索引访问页标签定义,不生成整本标签 入参: ctx 取消上下文, visit 区间访问函数 返回: error 数字树、标签定义或访问错误

func (*Reader) WalkPages

func (r *Reader) WalkPages(ctx context.Context, visit func(int, *Page) error) error

WalkPages 按页面顺序访问页面,不执行动作或访问外部资源 入参: ctx 取消上下文, visit 页面访问函数 返回: error 错误信息

func (*Reader) WalkStructure

func (r *Reader) WalkStructure(ctx context.Context, visit func(int, StructureItem) error) error

WalkStructure 按K声明顺序先序访问结构元素和内容引用,根的子项从零层开始 原始属性和引用由调用方按需解析,不读取页面内容流 入参: ctx 取消上下文, visit 零基层级和结构项的访问函数 返回: error 解析、结构、循环、取消或访问错误

func (*Reader) WalkStructureIDs

func (r *Reader) WalkStructureIDs(ctx context.Context, visit func(string, StructureItem) error) error

WalkStructureIDs 按名称树顺序访问元素标识和对应结构元素,标识保留原始字节 校验索引名称与元素ID一致,不扫描结构层级或检查元素归属 入参: ctx 取消上下文, visit 标识及结构元素的访问函数 返回: error 名称树、元素标识、取消或访问错误

func (*Reader) WalkStructureParents

func (r *Reader) WalkStructureParents(ctx context.Context, visit func(StructureParent) error) error

WalkStructureParents 按父树键及MCID递增访问父元素引用,跳过标记数组中的空槽 复用数字树校验,元素层级由WalkStructure校验,不扫描页面内容或改变结构树 入参: ctx 取消上下文, visit 父元素引用访问函数 返回: error 数字树、元素引用、取消或访问错误

func (*Reader) WalkThreeDOverlay

func (r *Reader) WalkThreeDOverlay(ctx context.Context, page *Page, source ThreeD, visitor Visitor) error

WalkThreeDOverlay 解释选定正交视图的叠加外观,映射到页面用户空间并裁剪到三维视口 调用方应在激活的静态视图上最后绘制,不用于手动导航或脚本修改后的场景 入参: ctx 取消上下文, page 所在页面, source 三维参数, visitor 图元访问器 返回: error 坐标、外观、能力或访问错误

func (*Reader) WalkType3Glyph

func (r *Reader) WalkType3Glyph(ctx context.Context, mark TextMark, index int, visitor Visitor) error

WalkType3Glyph 按文字位置解释Type3字形内容流并访问其中的图元 入参: ctx 取消上下文, mark 文字绘制信息, index 字形下标, visitor 图元访问器 返回: error 解析或访问错误

type ReaderOptions

type ReaderOptions struct {
	Password     []byte
	PasswordUTF8 bool
	Warning      func(Diagnostic)
	ShapeText    TextShaper
}

ReaderOptions 设置密码编码、结构诊断及生成注释外观时的文字整形 Warning非空时诊断并恢复可确定的结构、字体及解码声明,不修改输入数据 源读取、取消及认证错误仍返回,绘制诊断由Visitor.Warning控制 ShapeText用于横排纯文本字段、列表选项及注释标题,空值不生成需要整形的外观,已有外观不受影响

type Real

type Real float64

Real 表示实数对象

type Rectangle

type Rectangle struct {
	XMin, YMin, XMax, YMax float64
}

Rectangle 表示PDF用户空间中的矩形坐标

type Redaction

type Redaction struct {
	Regions           [][4]Point
	Overlay           *Stream
	InteriorColor     *[3]float64
	OverlayText       string
	Repeat            bool
	DefaultAppearance String
	Alignment         int
}

Redaction 保存待删改区域和移除内容后使用的覆盖属性,不表示内容已安全移除 Regions使用页面默认用户坐标,Overlay存在时其余覆盖属性不读取

type Reference

type Reference struct {
	Number     int64
	Generation int64
}

Reference 标识间接对象编号及代数

type ReferenceResolver

type ReferenceResolver func(context.Context, *Reader, ReferenceXObject) (*Page, error)

ReferenceResolver 由调用方提供目标页面,返回nil时使用代理内容 目标阅读器由调用方维护,须在本次遍历及访问器回调结束前保持可用

type ReferenceXObject

type ReferenceXObject struct {
	File      FileSpecification
	PageIndex int64
	PageLabel *string
	ID        []String
}

ReferenceXObject 保存引用表单的目标文件、页面选择及文件标识 PageLabel不为nil时按文本页标签选择,否则使用从0开始的PageIndex

type RemoteDestination

type RemoteDestination struct {
	Named      Object
	Page       int64
	Mode       Name
	Parameters Array
}

RemoteDestination 保存目标文档中的零基页码或原始命名目标,不引用源文档页面 Named仅为Name或String,非空时不使用Page、Mode和Parameters

type Rendition

type Rendition struct {
	Subtype      Name
	Name         string
	Clip         *MediaClip
	Alternatives []*Rendition
	Play         Dictionary
	Screen       Dictionary
	MustHonor    Dictionary
	BestEffort   Dictionary
	Dictionary   Dictionary
}

Rendition 保存媒体呈现及有序候选树,不自行选择播放器或执行脚本

func (*Rendition) Select

func (m *Rendition) Select(ctx context.Context, viable func(*Rendition) (bool, error)) (*Rendition, error)

Select 按深度优先顺序选择首个可用呈现,单次选择只检查每个共享节点一次 回调也检查选择器自身的约束,同次选择应使用一致的运行环境 入参: ctx 取消上下文, viable 调用方对设备、播放器和必须遵守约束的检查 返回: *Rendition 可用媒体呈现,无匹配返回空值, error 取消或检查错误

type RenditionAction

type RenditionAction struct {
	Annotation Reference
	Target     *ScreenAnnotation
	Operation  int
	Rendition  *Rendition
}

RenditionAction 描述媒体呈现操作,Annotation和Target分别引用原有或新增屏幕注解,须指定一项 Operation取0至4,依次表示播放并替换、停止、暂停、恢复、播放或恢复;0和4须提供Rendition 呈现及片段按结构化字段写出,Dictionary不参与写出;参数中的引用须属于当前文件 同一呈现、片段或文件指针复用输出资源,不读取外部文件,不执行播放或脚本

type RenditionPlayback

type RenditionPlayback struct {
	Annotation Annotation
	Page       Reference
	Operation  *int64
	Rendition  *Rendition
	Script     *JavaScriptAction
}

RenditionPlayback 保存媒体动作、屏幕归属及脚本后备操作,不执行播放或脚本 Operation为空表示仅有脚本;同时存在时Script优先,Operation用于无法执行脚本的环境 Page为屏幕声明的所属页,调用方可进一步检查其是否在所需页面集合中

type ReplacementText

type ReplacementText struct {
	Text   string
	Parent *ReplacementText
}

ReplacementText 保存整个内容区段的替换文本,Parent指向外层替换区段 Text允许为空,表示不提取该区段的原始字符;相邻区段之间不隐式增加空格

type ResetFormAction

type ResetFormAction struct {
	Fields    []ActionTarget
	AllFields bool
	Exclude   bool
}

ResetFormAction 保存表单重置范围,不修改字段值 AllFields表示Fields缺省,此时忽略Exclude;空数组与缺省范围不同

type RewriteOptions

type RewriteOptions struct {
	Information         Dictionary
	Images              map[Reference]image.Image
	ImageOptions        ImageWriteOptions
	LinkRegions         map[AnnotationLocation]LinkRegion
	LinkDestinations    map[AnnotationLocation]Destination
	LinkActions         map[AnnotationLocation][]NavigationAction
	OutlineDestinations map[Reference]Destination
	OutlineTitles       map[Reference]string
	OutlineActions      map[Reference][]NavigationAction
	OpenActions         []NavigationAction
	PageOpenActions     map[Reference][]NavigationAction
	PageCloseActions    map[Reference][]NavigationAction
	Attachments         map[string]*EmbeddedFile
	MovieAnnotations    map[Reference][]*MovieAnnotation
	ScreenAnnotations   map[Reference][]*ScreenAnnotation
	TextReplacements    map[Reference][]TextReplacement
	Optimization        OptimizeOptions
}

RewriteOptions 批量修改文档信息、图像、文字、链接、附件和动作,保留原加密配置 图像及页面引用须指向原文件的间接对象;空配置原样写出,不修改源对象 大纲通过原节点引用定位,标题使用UTF-8文字 OutlineActions替换整个动作序列,空序列移除动作及目标,不可与同节点的OutlineDestinations同时指定 LinkActions按相同规则替换链接动作,不可与同位置的LinkDestinations同时指定 OpenActions为nil时保留文档打开行为,非nil空列表清除,非空列表替换为指定动作序列 PageOpenActions和PageCloseActions按页面引用替换相应事件,空列表清除,不影响其他事件 Attachments按名称树原始键添加或替换附件,nil值删除该键,其他位置的文件引用不变 MovieAnnotations按页面追加视频注解,同一注解指针只能添加一次,可由MovieAction.Target引用 ScreenAnnotations按页面追加屏幕注解,可由RenditionAction.Target引用 TextReplacements按页面内容流中的文字对象序号写入整段替换文本,不改动字形及定位 Information按键更新文档信息字典,nil值删除字段,文本使用EncodeTextString编码,不同步XMP Optimization在同次写出中处理压缩及制作软件,Creator非空时覆盖Information中的Creator及Producer

type RichMedia

type RichMedia struct {
	Assets              []MediaAsset
	Configurations      []MediaConfiguration
	Views               []Dictionary
	Settings            Dictionary
	Dictionary          Dictionary
	Activation          Dictionary
	Deactivation        Dictionary
	Presentation        Dictionary
	ActiveConfiguration int
}

RichMedia 保存富媒体资源、配置、视图和播放设置,不执行脚本

type ScreenAnnotation

type ScreenAnnotation struct {
	Rect       Rectangle
	Title      string
	Appearance *Stream
	Actions    []NavigationAction
	Hidden     bool
}

ScreenAnnotation 描述媒体播放区域及点击动作,Rect使用默认用户空间,Title使用UTF-8文字 Appearance须为表单流,空值写出空白外观;嵌套引用按流所属Reader解析 Actions为空时不添加点击动作,不自动启动媒体,也不创建页面跳转 Hidden隐藏静态注解并关闭其鼠标交互,不禁止外部动作在该区域播放媒体

type Segment

type Segment struct {
	Operator string
	Points   []Point
}

Segment 保存直线、三次曲线或闭合路径,坐标已变换到页面用户空间

type ShadingPattern

type ShadingPattern struct {
	Paint      Paint
	Style      Style
	Background *Paint
}

ShadingPattern 保留着色图案的源画刷和内部状态,遍历时生成非隔离挖空组 Paint及Style只读,Background使用原始背景色,不经过渐变函数

func (*ShadingPattern) Walk

func (p *ShadingPattern) Walk(ctx context.Context, bounds Rectangle, visitor Visitor) error

Walk 在页面坐标范围内遍历背景和着色,不应用外层对象的几何或透明度 入参: ctx 取消上下文, bounds 求值范围, visitor 组及路径访问器 返回: error 参数、访问或取消错误

type ShapedGlyph

type ShapedGlyph struct {
	ID            uint16
	Cluster       int
	VisualOrder   int
	X, Y, Advance float64
	Width         float64
}

ShapedGlyph 保存整形后的字形编号、原文簇及千分之一字号的定位与推进量 Cluster为原文的符文索引,VisualOrder为簇从左到右的零起始连续序号,同簇字形共用序号 X和Y相对行起点及基线,横轴向右、纵轴向上,Advance为横向推进量 Width为字体程序的横向字宽,不含整形调整,同一字形须保持一致

type SoftMask

type SoftMask struct {
	Subtype    Name
	ColorSpace *ColorSpace
	Backdrop   []float64
	// contains filtered or unexported fields
}

SoftMask 保存透明度或亮度蒙版及其传递函数

func (*SoftMask) Transfer

func (m *SoftMask) Transfer(value float64) (float64, error)

Transfer 将蒙版透明度或亮度映射到最终不透明度 入参: value 蒙版采样值 返回: float64 限定在零至一之间的不透明度, error 传递函数错误

func (*SoftMask) Walk

func (m *SoftMask) Walk(visitor Visitor) error

Walk 访问蒙版图元,坐标与引用蒙版的页面一致 入参: visitor 蒙版图元访问器 返回: error 解析或访问错误

func (*SoftMask) WalkContext

func (m *SoftMask) WalkContext(ctx context.Context, visitor Visitor) error

WalkContext 使用本次取消上下文访问蒙版图元,不修改原始解析状态 入参: ctx 取消上下文, visitor 蒙版图元访问器 返回: error 解析、访问或取消错误

type Sound

type Sound struct {
	Stream      *Stream
	Rate        float64
	Channels    int
	Bits        int
	Encoding    Name
	Compression Name
	File        *FileSpecification
}

Sound 保存音频采样参数和数据流,不执行播放或格式转换 写出时File优先,其他情况解码Stream通用过滤器并按显式采样参数写出;CP从Stream字典复制 File按名称、说明、文件系统和内嵌内容写出,Dictionary不参与写出

type SoundAction

type SoundAction struct {
	Sound       Sound
	Volume      float64
	Synchronous bool
	Repeat      bool
	Mix         bool
}

SoundAction 保存音频及有效播放参数,不解码采样或执行播放 Volume取值范围[-1,1],Repeat出现时Synchronous无效

type SpotFunction

type SpotFunction struct {
	// contains filtered or unexported fields
}

SpotFunction 保存预定义或自定义的二维网点函数,编译后不依赖阅读器

func (*SpotFunction) Evaluate

func (f *SpotFunction) Evaluate(x, y float64) (float64, error)

Evaluate 求值网点函数,输入及输出限制到标准网点区间 入参: x 横向网点坐标, y 纵向网点坐标 返回: float64 网点排序值, error 非有限值或计算错误

type Stream

type Stream struct {
	Dictionary Dictionary
	Data       []byte
	// contains filtered or unexported fields
}

Stream 保存流字典及未经解码的数据 阅读器返回的流解码需与所属Reader串行调用,并保持数据源可读

func (*Stream) Decode

func (s *Stream) Decode() ([]byte, error)

Decode 解码通用流过滤器,图像专用过滤器由图像接口处理 阅读器返回的流按需解析参数引用,手工构造的流需提供直接参数 返回: []byte 解码数据, error 错误信息

func (*Stream) DecodeContext

func (s *Stream) DecodeContext(ctx context.Context) ([]byte, error)

DecodeContext 解码通用流过滤器,在读取及样本处理间检查取消 阅读器返回的流需与所属Reader串行调用,并保持数据源可读 入参: ctx 取消上下文 返回: []byte 独立解码数据, error 解码或取消错误

type String

type String []byte

String 保留字符串原始字节,不预设文本编码

func EncodeTextString

func EncodeTextString(value string) (String, error)

EncodeTextString 将Unicode文字编码为PDFDocEncoding或带字节序标记的UTF-16BE 入参: value UTF-8文字 返回: String PDF文本串, error 无效UTF-8编码

type StructureAttribute

type StructureAttribute struct {
	Reference  Reference
	Owner      Name
	Class      *Name
	Revision   int64
	Dictionary Dictionary
	Stream     *Stream
}

StructureAttribute 保存结构属性的所属方、类名和修订号,不合并同名属性 Class为空指针表示元素直接声明的属性,Stream非空时属性内容由调用方按需解码

type StructureContent

type StructureContent struct {
	Reference  Reference
	ParentKey  int64
	Dictionary Dictionary
	Stream     *Stream
}

StructureContent 保存内容引用的容器及父树索引,Stream非空时容器为数据流 Reference对MCR为页面或独立内容流,对OBJR为目标对象

type StructureItem

type StructureItem struct {
	Reference   Reference
	Parent      Reference
	Page        Reference
	Type        Name
	Tag         Name
	Revision    int64
	MCID        int64
	Stream      Reference
	StreamOwner Reference
	Target      Reference
	Dictionary  Dictionary
}

StructureItem 保存结构元素或内容引用,Type为StructElem、MCR或OBJR Tag和Revision仅用于结构元素,MCID仅用于MCR,Target仅用于OBJR Page对内容引用采用其自身或直属结构元素的Pg,不继承更上层元素的Pg Stream为空时MCR引用页面内容流,整数形式的MCR没有Dictionary

type StructureParent

type StructureParent struct {
	Element Reference
	Key     int64
	MCID    int64
}

StructureParent 保存父树键及结构元素引用,MCID为-1表示整对象,非负值表示内容流中的标记

type StructureTree

type StructureTree struct {
	Reference  Reference
	RoleMap    Dictionary
	ClassMap   Dictionary
	Dictionary Dictionary
}

StructureTree 保存逻辑结构根、角色映射和属性类,树索引及扩展信息保留在原始字典中

type Style

type Style struct {
	Fill, Stroke    Paint
	LineWidth       float64
	Cap, Join       int
	MiterLimit      float64
	Dash            []float64
	DashPhase       float64
	Clips           []Path
	StrokeAdjust    bool
	FillOverprint   bool
	StrokeOverprint bool
	OverprintMode   int
	RenderingIntent Name
	BlendMode       Name
	AlphaIsShape    bool
	SoftMask        *SoftMask
	Smoothness      *float64
	Antialias       *bool
	Halftone        *Halftone
	HalftoneOrigin  *Point
	Transfer        *TransferFunction
	ColorConversion ColorConversion
}

Style 保存绘制状态及按顺序相交的裁剪路径 Transfer在最终设备颜色转换及透明合成后应用,不预先改变Fill和Stroke HalftoneOrigin保存设置时的页面用户坐标,后续变换不移动原点,空值采用设备默认值

type SyntaxError

type SyntaxError struct {
	Offset  int64
	Message string
}

SyntaxError 表示PDF语法错误及其字节位置

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

Error 返回错误信息 返回: string 错误描述

type TextClip

type TextClip struct {
	Font                  *Font
	Glyphs                []Glyph
	Positions             []Point
	Matrix                Matrix
	Size, HorizontalScale float64
}

TextClip 保存参与裁剪的字形及页面定位

type TextMark

type TextMark struct {
	Object                *TextObject
	Sequence              *ContentSequence
	Replacement           *ReplacementText
	Font                  *Font
	Resources             Dictionary
	Glyphs                []Glyph
	Positions             []Point
	Matrix                Matrix
	StrokeMatrix          Matrix
	Size, HorizontalScale float64
	Style                 Style
	Mode                  int
	Clip                  *TextClip
	// contains filtered or unexported fields
}

TextMark 保存文字字形及其相对于文字矩阵的基线位置 Positions始终使用字形横排原点,竖排位置已扣除竖排原点向量 StrokeMatrix保留图形状态坐标变换,描边参数不受文字矩阵和字号影响 Mode保留有效绘制模式,Type3除不可见模式3外均按0交付,不产生文字裁剪 Object只读共享同一BT与ET边界,不同文字对象使用不同实例 Resources保留所在页面的只读资源,供未声明资源字典的Type3字形查找 Replacement保留所属替换文本区段,同一区段共享实例,不改变Glyphs中的原始字符映射

type TextObject

type TextObject struct {
	Knockout bool
}

TextObject 保留文字对象身份,Knockout为真时整段挖空,为假时逐字合成

type TextReplacement

type TextReplacement struct {
	First int
	Count int
	Text  string
}

TextReplacement 为连续文字对象指定整段原文,不改变绘制操作及字体编码 First为页面合并内容流中从零开始的BT序号,Count须大于零,不包含表单内部文字对象 Text使用UTF-8,允许为空;区段不得重叠、跨越已有内容标记边界或位于已有ActualText内部

type TextShaper

type TextShaper func(ctx context.Context, font *Font, text string, rightToLeft bool) ([]ShapedGlyph, error)

TextShaper 使用源字体整形单行文字,包括脚本分段和双向排列,不替换字体或修改源数据 字形编号须对应Font.Program;rightToLeft指定段落方向,断行后保持该方向 入参: ctx 取消上下文, font 源字体, text 单行原文, rightToLeft 段落是否从右向左 返回: []ShapedGlyph 逻辑簇顺序的定位字形, error 整形或取消错误

type ThreeD

type ThreeD struct {
	Stream               *Stream
	Format               Name
	Views                []Dictionary
	DefaultView          Object
	SelectedView         Dictionary
	Activation           Dictionary
	ActivationPolicy     ThreeDActivation
	AnimationStyle       ThreeDAnimation
	Projection           *ThreeDProjection
	Camera               ThreeDCamera
	Background           ThreeDBackground
	AnnotationBackground *[3]float64
	Lighting             ThreeDLighting
	Presentation         ThreeDPresentation
	Measurements         []ThreeDMeasurement
	AnnotationBox        Rectangle
	ViewBox              Rectangle
	Resources            Object
	OnInstantiate        *Stream
	Animation            Dictionary
	Interactive          bool
	Dictionary           Dictionary
}

ThreeD 保存3D数据、视图和激活参数,不解码模型或执行脚本 AnnotationBackground仅在面色要求宿主背景时读取,空值表示透明 AnnotationBox使用页面用户坐标,ViewBox以注解中心为原点

type ThreeDActivation

type ThreeDActivation struct {
	Activation, ActivationState     Name
	Deactivation, DeactivationState Name
	Toolbar, Navigator              bool
}

ThreeDActivation 保存3D注解的激活、停用及界面初始状态,不执行脚本

type ThreeDAnimation

type ThreeDAnimation struct {
	Style          Name
	PlayCount      int64
	TimeMultiplier float64
}

ThreeDAnimation 保存关键帧动画方式,负播放次数表示无限重复

type ThreeDBackground

type ThreeDBackground struct {
	ColorSpace       Object
	Color            Object
	RGB              *[3]float64
	EntireAnnotation bool
}

ThreeDBackground 保存不透明背景,未知颜色空间保留原值且RGB为空

type ThreeDCamera

type ThreeDCamera struct {
	Source        Name
	Matrix        [12]float64
	Path          []string
	CenterOfOrbit *float64
}

ThreeDCamera 保存相机来源,Source为空时使用模型中的视图 Matrix仅用于M来源,Path仅用于U3D来源;CenterOfOrbit为空时由阅读器确定

type ThreeDCrossSection

type ThreeDCrossSection struct {
	Center              [3]float64
	Axis                int
	Rotation            [3]float64
	Opacity             float64
	Color               [3]float64
	IntersectionVisible bool
	IntersectionColor   [3]float64
	Dictionary          Dictionary
}

ThreeDCrossSection 保存世界坐标中的剖切面,Axis为初始法线轴索引 Rotation按XYZ顺序旋转,Axis对应分量不参与旋转,正侧几何被裁去

type ThreeDLight

type ThreeDLight struct {
	Color, Direction [3]float64
	CameraAttached   bool
}

ThreeDLight 保存无限远光源,Direction表示光线发射方向,CameraAttached表示随相机转动

type ThreeDLighting

type ThreeDLighting struct {
	Subtype    Name
	Lights     []ThreeDLight
	Ambient    [3]float64
	Dictionary Dictionary
}

ThreeDLighting 保存标准灯光方案,Artwork沿用模型灯光,Ambient为材质漫反射增量

type ThreeDMarkup

type ThreeDMarkup struct {
	Annotation Annotation
	View       Dictionary
	Checksum   *[16]byte
	Dictionary Dictionary
}

ThreeDMarkup 保存三维批注的宿主、视图及可选模型校验和,不决定激活状态

func (ThreeDMarkup) MatchesView

func (m ThreeDMarkup) MatchesView(view Dictionary) bool

MatchesView 比较同一Reader内的视图对象身份,不将参数相同的不同视图合并 入参: view 当前选定视图 返回: bool 是否为绑定视图

type ThreeDMeasurement

type ThreeDMeasurement struct {
	Subtype         Name
	Name            string
	Plane           *[3]float64
	Anchors         [4]*[3]float64
	Parts           [2]*string
	Directions      [2]*[3]float64
	TextPosition    [3]float64
	TextX           *[3]float64
	TextY           *[3]float64
	TextBox         *[2]int64
	TextSize        float64
	Color           [3]float64
	Value           *float64
	Units           *string
	Precision       int64
	UserText        string
	Degrees         bool
	ExtensionLength float64
	ShowCircle      bool
	Radius          bool
	Comment         Reference
	Dictionary      Dictionary `json:"-"`
}

ThreeDMeasurement 保存三维测量及批注参数,不执行投影或重算声明的测量值 空指针表示字段不适用或未提供,Comment不递归展开关联批注

type ThreeDNode

type ThreeDNode struct {
	Name       string
	Opacity    *float64
	Visible    *bool
	Matrix     *[12]float64
	Dictionary Dictionary
}

ThreeDNode 保存PDF三维节点覆盖,空透明度和可见性沿父节点继承 Matrix为空时保留原变换,非空时替换相对父节点的变换

type ThreeDPresentation

type ThreeDPresentation struct {
	RenderMode    *ThreeDRenderMode
	Overlay       *Stream
	CrossSections []ThreeDCrossSection
	Nodes         []ThreeDNode
	ResetNodes    bool
}

ThreeDPresentation 保存当前视图的绘制模式、叠加外观及节点状态,未知绘制模式按默认处理

type ThreeDProjection

type ThreeDProjection struct {
	Subtype, Clipping                       Name
	Near, Far                               *float64
	FieldOfView                             float64
	PerspectiveBinding, OrthographicBinding Name
	PerspectiveDiameter, OrthographicScale  float64
}

ThreeDProjection 保存相机投影参数,空裁剪距离表示自动裁剪或未限定远平面 PerspectiveBinding为空时使用PerspectiveDiameter,正交缩放不采用透视参数

func (ThreeDProjection) ScaleFactor

func (p ThreeDProjection) ScaleFactor(viewBox, annotationBox Rectangle) (float64, error)

ScaleFactor 按PDF标准表305计算投影倍率,不按模型包围盒重新适配 透视投影的相机坐标还需除以各自的z坐标;返回值不含视口平移 入参: viewBox 三维视口, annotationBox 注解区域 返回: float64 投影倍率, error 投影参数或尺寸错误

type ThreeDRenderMode

type ThreeDRenderMode struct {
	Subtype              Name
	AuxiliaryColor       [3]float64
	FaceColor            *[3]float64
	AnnotationBackground bool
	Opacity              float64
	CreaseAngle          float64
	Dictionary           Dictionary
}

ThreeDRenderMode 保存三维绘制参数,FaceColor为空时沿用视图背景色 AnnotationBackground为真时改用宿主注解背景色,对应未知的面色名称 Opacity为附加不透明度,CreaseAngle为轮廓夹角,不适用的字段保持默认值

type TilingPattern

type TilingPattern struct {
	BBox      Rectangle
	Matrix    Matrix
	XStep     float64
	YStep     float64
	PaintType int
	// contains filtered or unexported fields
}

TilingPattern 保存平铺图案的单元几何及独立内容流

func (*TilingPattern) Walk

func (p *TilingPattern) Walk(ctx context.Context, base Paint, visitor Visitor) error

Walk 独立解释图案单元内容,保留图案边界与无色图案的基色 入参: ctx 取消上下文, base 无色图案基色, visitor 绘制访问器 返回: error 解析或访问错误

type TransferFunction

type TransferFunction struct {
	// contains filtered or unexported fields
}

TransferFunction 保存红、绿、蓝及灰度的传递函数,可独立于阅读器并发求值 输入输出均按加色分量解释,空值表示恒等设备默认值

func (*TransferFunction) Apply

func (f *TransferFunction) Apply(values []float64, model, source Name) ([4]float64, error)

Apply 对原生设备分量应用传递函数,减色分量在求值前后取补值 入参: values 颜色转换后的单位分量, model DeviceGray、DeviceRGB或DeviceCMYK, source 原始颜色空间族 返回: [4]float64 原生设备输出分量, error 分量或求值错误

func (*TransferFunction) Evaluate

func (f *TransferFunction) Evaluate(value float64, channel int) (float64, error)

Evaluate 计算指定通道的加色分量,输出裁切至单位范围 入参: value 单位输入值, channel 红绿蓝灰通道序号0至3 返回: float64 加色输出值, error 输入或求值错误

func (*TransferFunction) SelectChannels

func (f *TransferFunction) SelectChannels(channels [4]bool) *TransferFunction

SelectChannels 保留不透明通道的函数,其余通道使用恒等设备默认值 入参: channels 红绿蓝灰通道选择,四色设备依次对应青品黄黑 返回: *TransferFunction 只读函数,未改变时复用原对象,全恒等时为空

type UnicodeMap

type UnicodeMap map[string]string

UnicodeMap 保存字符码到Unicode文本的映射,不将字符码等同于字形编号

func ParseUnicodeMap

func ParseUnicodeMap(data []byte) (UnicodeMap, error)

ParseUnicodeMap 读取ToUnicode映射中的字符与范围定义 入参: data 已解码的CMap数据 返回: UnicodeMap 字符映射, error 错误信息

func ParseUnicodeMapContext

func ParseUnicodeMapContext(ctx context.Context, data []byte) (UnicodeMap, error)

ParseUnicodeMapContext 读取Unicode映射,在解析、展开及继承时检查取消 入参: ctx 取消上下文, data 已解码的CMap数据 返回: UnicodeMap 完整映射, error 解析或取消错误

type UnsupportedError

type UnsupportedError struct {
	Feature string
}

UnsupportedError 表示尚未支持的PDF能力

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

Error 返回错误信息 返回: string 错误描述

type VerticalMetrics

type VerticalMetrics struct {
	Advance float64
	Origin  Point
}

VerticalMetrics 保存千分之一字形单位的竖排纵向位移及相对于横排原点的位置

type Visitor

type Visitor struct {
	Path            func(PathMark) error
	Text            func(TextMark) error
	Image           func(ImageMark) error
	Form            func(FormMark, func(Visitor) error) error
	Group           func(GroupMark, func(Visitor) error) error
	MarkedContent   func(MarkedContentMark) error
	OptionalContent func(Object) (bool, error)
	Reference       ReferenceResolver
	PostScript      func(PostScriptMark) error
	ColorantDevice  *ColorantDevice
	Halftones       map[string]*Halftone
	Warning         func(Diagnostic)
}

Visitor 按内容顺序接收页面绘制对象,缺少对应绘制回调时返回错误 Warning非空时报告空Type3字形、缺失的ExtGState或Shading资源及未保留的内容语义,其他解析错误仍返回错误 OptionalContent可覆盖内容区段及XObject的可选内容状态,缺省使用文档默认配置 Reference可提供引用表单的目标页面,缺省或返回nil时绘制代理内容 ColorantDevice声明输出设备,保留其可用色料,实际分色求值与合成由访问器完成 Halftones提供只读设备命名网屏,优先于文件中的同名备用定义 Form可保留普通表单边界,缺省直接展开;透明表单仍由Group接收 Form的子访问器接收已变换并裁剪的图元,不应再次应用表单矩阵 Form及Group的子访问器未指定内容标记、可选内容及警告回调时沿用上层回调 Warning非空时诊断无效内容指令及可恢复外观,保留有效绘制和已有文字定位

type WindowsLaunchParameters

type WindowsLaunchParameters struct {
	File       String
	Directory  String
	Operation  string
	Parameters String
}

WindowsLaunchParameters 保存Windows启动参数,路径和参数保留原始字节 Operation缺省为open,Parameters为空不代表允许执行应用程序

Source Files

Jump to

Keyboard shortcuts

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