Documentation
¶
Overview ¶
Package config 定义 PDF 导入配置,不依赖 PDF 解析器,供 converter 与导入器共享。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrLimitExceeded = errors.New("PDF 导入超过资源上限")
View Source
var ErrUnsupported = errors.New("PDF 导入遇到无法保留的内容")
Functions ¶
This section is empty.
Types ¶
type Diagnostic ¶
type Diagnostic struct {
Code string
Page int
Object int
Generation int
Resource string
Message string
}
Diagnostic 描述无法完整保留的内容。Page 从 1 开始,未知的对象编号为 0。
type JPXBackend ¶
type JPXBackend string
JPXBackend selects the JPEG 2000 decoder used for PDF JPX images. The OpenJPEG backend requires a Linux build with CGO_ENABLED=1 and -tags openjpeg.
const ( JPXBackendGo JPXBackend = "go" JPXBackendOpenJPEG JPXBackend = "openjpeg" )
type LimitError ¶
LimitError 可通过 errors.Is(err, ErrLimitExceeded) 和 errors.As 识别。 Actual 是已观察到的用量;解码提前终止时为超过上限的最小已知用量。
func (*LimitError) Error ¶
func (e *LimitError) Error() string
func (*LimitError) Unwrap ¶
func (e *LimitError) Unwrap() error
type Limits ¶
type Limits struct {
// 字节预算分别作用于原始输入、单编码流、单解码流和累计解码流。
MaxInputBytes int64
MaxPages int64
// MaxObjects 同时约束对象数及 xref 可引用的编号范围。
MaxObjects int64
MaxStreamBytes int64
MaxDecodedStreamBytes int64
MaxTotalDecodedBytes int64
MaxImagePixels int64
MaxTotalImagePixels int64
MaxFontBytes int64
MaxOutputObjects int64
// MaxOperations 计入内容解析、映射展开、遮罩/网格与 Type 4 函数解析和求值。
MaxOperations int64
MaxDepth int64
}
Limits 控制一次转换的资源预算。零值字段使用默认值,负值无效。
func DefaultLimits ¶
func DefaultLimits() Limits
type Options ¶
type Options struct {
Limits Limits
Strict bool
ImageMode ImageMode
JPEGQuality int
JPXBackend JPXBackend
OnDiagnostic func(Diagnostic)
}
Options 控制 PDF 导入。Strict 遇到已报告的内容缺失或近似转换即失败, 不代表完整实现 PDF 规范。OnDiagnostic 在转换协程中同步执行;取消该转换的 context 会原样返回 ctx.Err()。并行转换共用回调时,调用方应自行同步共享数据。
Click to show internal directories.
Click to hide internal directories.