feat(转换能力): 持零宽链接边框
build.yaml / build (push) Successful in 41s

This commit is contained in:
xiaoqidun committed 2026-09-25 18:14:47 +08:00
1 parent bbc8d59bdb
commit 725ea0eceb
3 files changed
+26 -8

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ require (
github.com/tdewolff/canvas v0.0.0-20260923214215-09804640d00c github.com/tdewolff/canvas v0.0.0-20260923214215-09804640d00c
github.com/tdewolff/font v0.0.0-20260913163313-54f98bb59ee6 github.com/tdewolff/font v0.0.0-20260913163313-54f98bb59ee6
github.com/xiaoqidun/jbig2 v1.1.1 github.com/xiaoqidun/jbig2 v1.1.1
github.com/xiaoqidun/pdfgo v0.0.0-20260925061819-c89bfccf349d github.com/xiaoqidun/pdfgo v0.0.0-20260925101147-ee88b22d9f03
golang.org/x/crypto v0.57.0 golang.org/x/crypto v0.57.0
golang.org/x/image v0.46.0 golang.org/x/image v0.46.0
golang.org/x/text v0.42.0 golang.org/x/text v0.42.0
+2 -2
View File
@@ -60,8 +60,8 @@ github.com/tdewolff/test v1.0.12 h1:7F21DqIajswxuche0geHdrUZRCWE4oko4b7bcmkkrxk=
github.com/tdewolff/test v1.0.12/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= 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 h1:SjliS9ZO0e9HX5oYUfBuXrfFsXhWricrSz+XY4zORDI=
github.com/xiaoqidun/jbig2 v1.1.1/go.mod h1:8QonVWtENmh2kc6l+leqeGl7psb79DWlHDkCpdChjfQ= github.com/xiaoqidun/jbig2 v1.1.1/go.mod h1:8QonVWtENmh2kc6l+leqeGl7psb79DWlHDkCpdChjfQ=
github.com/xiaoqidun/pdfgo v0.0.0-20260925061819-c89bfccf349d h1:hjdo01d4EsiNe9l0JNyc+Bqfrvdj9XGG786EYxAx3yw= github.com/xiaoqidun/pdfgo v0.0.0-20260925101147-ee88b22d9f03 h1:aYnf/5Wz2sS68w+Tr7G/cfiw9p70RBE/dmgxwGbz21k=
github.com/xiaoqidun/pdfgo v0.0.0-20260925061819-c89bfccf349d/go.mod h1:/D0XHgfZ7xNhix95swpNaThpuqoJjVR5wIadogtR5pI= github.com/xiaoqidun/pdfgo v0.0.0-20260925101147-ee88b22d9f03/go.mod h1:/D0XHgfZ7xNhix95swpNaThpuqoJjVR5wIadogtR5pI=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yuin/goldmark v1.8.5 h1:r6N5afV5qj/5S4UTch8agZHJ8UxNCMwX7WjkkJam2NA= github.com/yuin/goldmark v1.8.5 h1:r6N5afV5qj/5S4UTch8agZHJ8UxNCMwX7WjkkJam2NA=
+23 -5
View File
@@ -41,7 +41,7 @@ func (p *pdfImporter) annotations(ctx context.Context, page *pdfgo.Page, strict
if annotation.Subtype != "Link" { if annotation.Subtype != "Link" {
return &pdfgo.UnsupportedError{Feature: "annotation " + string(annotation.Subtype)} return &pdfgo.UnsupportedError{Feature: "annotation " + string(annotation.Subtype)}
} }
for _, key := range []pdfgo.Name{"AP", "AA", "BS", "OC"} { for _, key := range []pdfgo.Name{"AP", "AA", "OC"} {
if dict[key] != nil { if dict[key] != nil {
return &pdfgo.UnsupportedError{Feature: fmt.Sprintf("link annotation field %q", key)} return &pdfgo.UnsupportedError{Feature: fmt.Sprintf("link annotation field %q", key)}
} }
@@ -57,13 +57,31 @@ func (p *pdfImporter) annotations(ctx context.Context, page *pdfgo.Page, strict
return &pdfgo.UnsupportedError{Feature: "link annotation flags"} return &pdfgo.UnsupportedError{Feature: "link annotation flags"}
} }
} }
border, err := p.reader.Resolve(dict["Border"]) borderStyle, err := p.reader.Resolve(dict["BS"])
if err != nil { if err != nil {
return err return err
} }
array, ok := border.(pdfgo.Array) if borderStyle != nil {
if !ok || len(array) != 3 || (array[2] != pdfgo.Integer(0) && array[2] != pdfgo.Real(0)) { style, ok := borderStyle.(pdfgo.Dictionary)
return &pdfgo.UnsupportedError{Feature: "visible link border"} if !ok {
return fmt.Errorf("invalid PDF link border style")
}
width, err := p.reader.Resolve(style["W"])
if err != nil {
return err
}
if width != pdfgo.Integer(0) && width != pdfgo.Real(0) {
return &pdfgo.UnsupportedError{Feature: "visible link border"}
}
} else {
border, err := p.reader.Resolve(dict["Border"])
if err != nil {
return err
}
array, ok := border.(pdfgo.Array)
if !ok || len(array) < 3 || (array[2] != pdfgo.Integer(0) && array[2] != pdfgo.Real(0)) {
return &pdfgo.UnsupportedError{Feature: "visible link border"}
}
} }
action := Action{Event: "CLICK"} action := Action{Event: "CLICK"}
target := dict["Dest"] target := dict["Dest"]