mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
1 parent
299c2cbfdc
commit
8ddc2fdeed
7 files changed
+192
-109
No files matched your search
@@ -160,6 +160,16 @@ func renderPage(args []js.Value) (any, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
links := make([]any, len(page.Links))
|
||||
for i, link := range page.Links {
|
||||
links[i] = map[string]any{
|
||||
"uri": link.URI,
|
||||
"x": link.Box.X,
|
||||
"y": link.Box.Y,
|
||||
"width": link.Box.W,
|
||||
"height": link.Box.H,
|
||||
}
|
||||
}
|
||||
return successResult(map[string]any{
|
||||
"index": page.Index,
|
||||
"number": page.Number,
|
||||
@@ -167,6 +177,7 @@ func renderPage(args []js.Value) (any, error) {
|
||||
"width": page.Width,
|
||||
"height": page.Height,
|
||||
"svg": page.SVG,
|
||||
"links": links,
|
||||
}), nil
|
||||
}
|
||||
|
||||
|
||||
+12
-7
@@ -156,12 +156,13 @@ type PageInfo struct {
|
||||
|
||||
// PageSVG 页面SVG结果
|
||||
type PageSVG struct {
|
||||
Index int `json:"index"`
|
||||
Number int `json:"number"`
|
||||
ID string `json:"id"`
|
||||
Width float64 `json:"width"`
|
||||
Height float64 `json:"height"`
|
||||
SVG string `json:"svg"`
|
||||
Index int `json:"index"`
|
||||
Number int `json:"number"`
|
||||
ID string `json:"id"`
|
||||
Width float64 `json:"width"`
|
||||
Height float64 `json:"height"`
|
||||
SVG string `json:"svg"`
|
||||
Links []ofdgo.PageLink `json:"-"`
|
||||
}
|
||||
|
||||
// ExportFormat 导出格式
|
||||
@@ -382,7 +383,11 @@ func (s *Session) RenderPageSVG(index int) (PageSVG, error) {
|
||||
if err := s.Renderer.RenderToSVG(page, &buf); err != nil {
|
||||
return PageSVG{}, err
|
||||
}
|
||||
return PageSVG{Index: index, Number: index + 1, ID: pageRef.ID, Width: box.W, Height: box.H, SVG: buf.String()}, nil
|
||||
links, err := s.Renderer.PageLinks(page)
|
||||
if err != nil {
|
||||
return PageSVG{}, err
|
||||
}
|
||||
return PageSVG{Index: index, Number: index + 1, ID: pageRef.ID, Width: box.W, Height: box.H, SVG: buf.String(), Links: links}, nil
|
||||
}
|
||||
|
||||
// ExportPage 导出单页
|
||||
|
||||
Reference in new issue
Block a user