feat(前端界面): OFDGo WebUI可选是否渲染注解
build.yaml / build (push) Successful in 35s

This commit is contained in:
2026-07-07 13:10:55 +08:00
parent 98244f2bb7
commit f1d1f5ed2d
5 changed files with 35 additions and 25 deletions
+5 -4
View File
@@ -79,22 +79,23 @@ func safeCall(fn func([]js.Value) (any, error), args []js.Value) (data any, err
// 入参: args 浏览器参数
// 返回: any 文档信息, error 错误信息
func openDocument(args []js.Value) (any, error) {
if len(args) == 0 {
return nil, fmt.Errorf("missing ofd data")
if len(args) < 3 {
return nil, fmt.Errorf("missing open arguments")
}
data, err := bytesFromJS(args[0])
if err != nil {
return nil, err
}
fonts, err := fontsFromJS(jsArg(args, 1))
fonts, err := fontsFromJS(args[1])
if err != nil {
return nil, err
}
renderAnnotations := args[2].Bool()
if currentSession != nil {
_ = currentSession.Close()
currentSession = nil
}
session, err := Open(data, OpenOptions{Fonts: fonts})
session, err := Open(data, OpenOptions{Fonts: fonts, RenderAnnotations: renderAnnotations})
if err != nil {
return nil, err
}
+3 -1
View File
@@ -29,7 +29,8 @@ import (
// OpenOptions 打开OFD文档选项
type OpenOptions struct {
Fonts []FontFile
Fonts []FontFile
RenderAnnotations bool
}
// FontFile 字体文件
@@ -144,6 +145,7 @@ func Open(data []byte, opts OpenOptions) (*Session, error) {
}
rendererOptions = append(rendererOptions, ofdgo.WithFontFS(fontFS))
}
rendererOptions = append(rendererOptions, ofdgo.WithAnnotations(opts.RenderAnnotations))
return &Session{Reader: reader, Renderer: ofdgo.NewRenderer(reader, rendererOptions...), doc: doc}, nil
}