mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 14:16:55 +08:00
1 parent
b8ed92221b
commit
9d212b6fd0
12 files changed
+24
-16
No files matched your search
@@ -9,7 +9,7 @@ require (
|
||||
github.com/tdewolff/canvas v0.0.0-20260923214215-09804640d00c
|
||||
github.com/tdewolff/font v0.0.0-20260913163313-54f98bb59ee6
|
||||
github.com/xiaoqidun/jbig2 v1.1.1
|
||||
github.com/xiaoqidun/pdfgo v0.0.0-20260929061025-aafe265ab017
|
||||
github.com/xiaoqidun/pdfgo v0.0.0-20260929063458-1c0de5ea8fb5
|
||||
golang.org/x/crypto v0.57.0
|
||||
golang.org/x/image v0.46.0
|
||||
golang.org/x/text v0.42.0
|
||||
|
||||
@@ -62,8 +62,8 @@ github.com/tdewolff/test v1.0.12 h1:7F21DqIajswxuche0geHdrUZRCWE4oko4b7bcmkkrxk=
|
||||
github.com/tdewolff/test v1.0.12/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
|
||||
github.com/xiaoqidun/jbig2 v1.1.1 h1:SjliS9ZO0e9HX5oYUfBuXrfFsXhWricrSz+XY4zORDI=
|
||||
github.com/xiaoqidun/jbig2 v1.1.1/go.mod h1:8QonVWtENmh2kc6l+leqeGl7psb79DWlHDkCpdChjfQ=
|
||||
github.com/xiaoqidun/pdfgo v0.0.0-20260929061025-aafe265ab017 h1:VS7X7ESz+3xXj9A1AlmAwQgzxXrWvSfaMklKoIBpUKQ=
|
||||
github.com/xiaoqidun/pdfgo v0.0.0-20260929061025-aafe265ab017/go.mod h1:4Pf0JO0BEf1uzRY+uZjlMjN/OPn3PYa0YMi6cqPPTLQ=
|
||||
github.com/xiaoqidun/pdfgo v0.0.0-20260929063458-1c0de5ea8fb5 h1:V6//X67UzIETLaHx4YCNxj0Ai38rylYfMNIM6eOnPs0=
|
||||
github.com/xiaoqidun/pdfgo v0.0.0-20260929063458-1c0de5ea8fb5/go.mod h1:4Pf0JO0BEf1uzRY+uZjlMjN/OPn3PYa0YMi6cqPPTLQ=
|
||||
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
github.com/yuin/goldmark v1.8.5 h1:r6N5afV5qj/5S4UTch8agZHJ8UxNCMwX7WjkkJam2NA=
|
||||
|
||||
@@ -3738,7 +3738,7 @@ func setEditorColor(fill *ofdgo.FillColor, value string) error {
|
||||
}
|
||||
|
||||
// editorColorHex 将当前文档纯色转换为浏览器色值
|
||||
// 入参: color 颜色
|
||||
// 入参: value 颜色
|
||||
// 返回: string 十六进制色值
|
||||
func editorColorHex(value *ofdgo.FillColor) string {
|
||||
converted, err := currentEditor.Color(value)
|
||||
|
||||
+1
-1
@@ -494,7 +494,7 @@ func (e *Editor) addImage(data []byte, config image.Config, format string, decod
|
||||
}
|
||||
|
||||
// AddObject 按添加顺序放入正文图层,支持文字、路径和图片,自动分配对象ID
|
||||
// 支持基本颜色、直接资源引用及路径裁剪,不支持动作、渐变及复合图元
|
||||
// 支持已注册资源、颜色、渐变、裁剪和动作;复合图元仅支持当前文档原对象的保真复制
|
||||
// 入参: page 页面索引, object 对象内容,添加后不再引用调用方的可变数据
|
||||
// 返回: string 对象标识, error 错误信息
|
||||
func (e *Editor) AddObject(page int, object GraphicObject) (string, error) {
|
||||
|
||||
@@ -107,6 +107,8 @@ func (e *Editor) ImportImages(ctx context.Context, sources []ImagePageSource, at
|
||||
}
|
||||
|
||||
// addImagePage 保留原图并按方向、物理尺寸与纸张选项建页
|
||||
// 入参: data 图片数据, options 建页选项
|
||||
// 返回: int 从0开始的页面索引, error 错误信息
|
||||
func (e *Editor) addImagePage(data []byte, options ImagePageOptions) (int, error) {
|
||||
config, format, err := image.DecodeConfig(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
@@ -155,6 +157,8 @@ func (e *Editor) addImagePage(data []byte, options ImagePageOptions) (int, error
|
||||
}
|
||||
|
||||
// imagePageOrientation 将EXIF方向映射为单位图像到页面局部坐标的变换
|
||||
// 入参: orientation EXIF方向值, w、h 图片在页面上的宽高,单位为毫米
|
||||
// 返回: Matrix 图像坐标变换
|
||||
func imagePageOrientation(orientation int, w, h float64) Matrix {
|
||||
switch orientation {
|
||||
case 2:
|
||||
|
||||
@@ -35,7 +35,7 @@ type editorResourceRefs struct {
|
||||
}
|
||||
|
||||
// compactSourceResources 在保存副本中清理无引用字体和图片,并裁剪可完整确认用字的原有字体
|
||||
// 按GB/T 33190-2016附录A检查标识和路径引用,包括模板、注释、底纹、裁剪、版本和其他文档
|
||||
// 按GB/T33190-2016附录A检查标识和路径引用,包括模板、注释、底纹、裁剪、版本和其他文档
|
||||
// 全包检查保留孤立XML中的引用;未知命名空间、扩展数据或无法解析的XML使本次清理跳过
|
||||
// 入参: parts 已修改和新增的包内条目, progress 保存进度回调
|
||||
// 返回: map[string]bool 可移除的二进制条目, error 读取错误
|
||||
|
||||
+1
-1
@@ -1203,7 +1203,7 @@ func parseCFFWidths(data []byte, numGlyphs int) ([]uint16, error) {
|
||||
}
|
||||
|
||||
// scanCharStringWidth 扫描CharString获取宽度
|
||||
// 入参: data CharString数据, nominal, def 默认宽度值
|
||||
// 入参: data CharString数据, nominal 名义宽度, def 默认宽度
|
||||
// 返回: float64 宽度值
|
||||
func scanCharStringWidth(data []byte, nominal, def float64) float64 {
|
||||
stackDepth := 0
|
||||
|
||||
@@ -28,6 +28,8 @@ type imagePageInfo struct {
|
||||
}
|
||||
|
||||
// imagePageMetadata 读取PNG物理尺寸与JPEG的JFIF、EXIF信息,EXIF密度优先于JFIF
|
||||
// 入参: data 图片数据, format 图像格式, dpi 缺少物理密度时使用的DPI
|
||||
// 返回: imagePageInfo 方向与横纵DPI, error 元数据错误
|
||||
func imagePageMetadata(data []byte, format string, dpi float64) (imagePageInfo, error) {
|
||||
info := imagePageInfo{orientation: 1, xdpi: dpi, ydpi: dpi}
|
||||
var exif []byte
|
||||
@@ -121,6 +123,8 @@ func imagePageMetadata(data []byte, format string, dpi float64) (imagePageInfo,
|
||||
}
|
||||
|
||||
// imageExifMetadata 只读取主图IFD中的方向和密度,不跟随缩略图与其他目录
|
||||
// 入参: data EXIF中的TIFF数据
|
||||
// 返回: int EXIF方向值,未声明时为1, float64 横向DPI, float64 纵向DPI, error 元数据错误
|
||||
func imageExifMetadata(data []byte) (int, float64, float64, error) {
|
||||
invalid := fmt.Errorf("invalid EXIF image metadata")
|
||||
if len(data) < 8 {
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ func (m *MeshShading) outline() GeometryPath {
|
||||
return path
|
||||
}
|
||||
|
||||
// resolveMesh 按GB/T 33190的三角形连接规则解析网格
|
||||
// resolveMesh 按GB/T33190的三角形连接规则解析网格
|
||||
// 入参: fill 网格颜色
|
||||
// 返回: *MeshShading 网格画刷, error 无效控制点
|
||||
func (r *Renderer) resolveMesh(fill *FillColor) (*MeshShading, error) {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
// appearanceAnnotation 将PDF静态外观转换为对应类型的OFD注解
|
||||
// 入参: ctx取消上下文, page PDF页面, annotation PDF注解, actions 外观区域的动作
|
||||
// 入参: ctx 取消上下文, page PDF页面, annotation PDF注解, actions 外观区域的动作
|
||||
// 返回: error 外观或转换错误
|
||||
func (p *pdfImporter) appearanceAnnotation(ctx context.Context, page *pdfgo.Page, annotation pdfgo.Annotation, actions ...Action) error {
|
||||
for _, key := range []pdfgo.Name{"AA", "OC", "A"} {
|
||||
|
||||
+5
-5
@@ -41,7 +41,7 @@ type digitalVerifyResult struct {
|
||||
CertInfo SignatureCertInfo
|
||||
}
|
||||
|
||||
// gbtSignedData GB/T 35275 SignedData结构
|
||||
// gbtSignedData GB/T35275 SignedData结构
|
||||
type gbtSignedData struct {
|
||||
Version int
|
||||
ContentDigest []byte
|
||||
@@ -149,7 +149,7 @@ func verifyRawPublicKeySignature(method, digestMethod string, signedValue, signe
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// verifyGBT35275SignedData 验证GB/T 35275 SignedData签名值
|
||||
// verifyGBT35275SignedData 验证GB/T35275 SignedData签名值
|
||||
// 入参: signedValue 签名值, signedData 被签名原文, options 验证选项
|
||||
// 返回: *digitalVerifyResult 验证结果, error 错误信息
|
||||
func verifyGBT35275SignedData(signedValue, signedData []byte, options *signatureVerifyOptions) (*digitalVerifyResult, error) {
|
||||
@@ -256,7 +256,7 @@ func verifyGBT35275SignedData(signedValue, signedData []byte, options *signature
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// normalizeGBT35275SignedValue 规范化GB/T 35275 SignedData编码
|
||||
// normalizeGBT35275SignedValue 规范化GB/T35275 SignedData编码
|
||||
// 入参: data 签名值数据
|
||||
// 返回: []byte 定长编码数据, bool 是否为SignedData
|
||||
func normalizeGBT35275SignedValue(data []byte) ([]byte, bool) {
|
||||
@@ -274,7 +274,7 @@ func normalizeGBT35275SignedValue(data []byte) ([]byte, bool) {
|
||||
return der, true
|
||||
}
|
||||
|
||||
// gbtContentType 读取GB/T 35275内容类型
|
||||
// gbtContentType 读取GB/T35275内容类型
|
||||
// 入参: data DER编码数据
|
||||
// 返回: string 内容类型, bool 是否完成解析
|
||||
func gbtContentType(data []byte) (string, bool) {
|
||||
@@ -391,7 +391,7 @@ func wrapBERValue(tag, content []byte) []byte {
|
||||
return append(out, content...)
|
||||
}
|
||||
|
||||
// parseGBT35275SignedData 解析GB/T 35275 SignedData
|
||||
// parseGBT35275SignedData 解析GB/T35275 SignedData
|
||||
// 入参: data 签名值数据
|
||||
// 返回: *gbtSignedData SignedData结构, error 错误信息
|
||||
func parseGBT35275SignedData(data []byte) (*gbtSignedData, error) {
|
||||
|
||||
+2
-2
@@ -40,8 +40,8 @@ const (
|
||||
type SignatureWriteMode uint8
|
||||
|
||||
// SignatureWriteOptions 最终包签署选项,不修改Editor或调用方的原件
|
||||
// SM2数字签名使用GB/T 35275-2017消息结构;RSA/ECDSA使用裸签名,验签需WithSignatureCert
|
||||
// Seal仅接受已有合法SES v4电子印章,使用SM2/SM3,不声明GM/T 0031-2025兼容
|
||||
// SM2数字签名使用GB/T35275-2017消息结构;RSA/ECDSA使用裸签名,验签需WithSignatureCert
|
||||
// Seal仅接受已有合法SES v4电子印章,使用SM2/SM3,不声明GM/T0031-2025兼容
|
||||
// TrustRoots必须显式指定;证书吊销状态和外部业务授权由调用方在签署前检查
|
||||
type SignatureWriteOptions struct {
|
||||
Signer crypto.Signer
|
||||
|
||||
Reference in new issue
Block a user