pass viewbox coords in
This commit is contained in:
parent
51d0000e0f
commit
5e2ce123fc
2 changed files with 11 additions and 11 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -489,7 +490,15 @@ func renderPDF(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, ske
|
|||
}
|
||||
|
||||
viewboxSlice := appendix.FindViewboxSlice(svg)
|
||||
err = pdf.AddPDFPage(pngImg, currBoardPath, themeID, rootFill, diagram.Shapes, pad, viewboxSlice)
|
||||
viewboxX, err := strconv.ParseFloat(viewboxSlice[0], 64)
|
||||
if err != nil {
|
||||
return svg, err
|
||||
}
|
||||
viewboxY, err := strconv.ParseFloat(viewboxSlice[1], 64)
|
||||
if err != nil {
|
||||
return svg, err
|
||||
}
|
||||
err = pdf.AddPDFPage(pngImg, currBoardPath, themeID, rootFill, diagram.Shapes, pad, viewboxX, viewboxY)
|
||||
if err != nil {
|
||||
return svg, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package pdf
|
|||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/jung-kurt/gofpdf"
|
||||
|
|
@ -59,7 +58,7 @@ func (g *GoFPDF) GetFillRGB(themeID int64, fill string) (color.RGB, error) {
|
|||
return color.Hex2RGB(fill)
|
||||
}
|
||||
|
||||
func (g *GoFPDF) AddPDFPage(png []byte, boardPath []string, themeID int64, fill string, shapes []d2target.Shape, pad int64, viewboxSlice []string) error {
|
||||
func (g *GoFPDF) AddPDFPage(png []byte, boardPath []string, themeID int64, fill string, shapes []d2target.Shape, pad int64, viewboxX, viewboxY float64) error {
|
||||
var opt gofpdf.ImageOptions
|
||||
opt.ImageType = "png"
|
||||
imageInfo := g.pdf.RegisterImageOptionsReader(strings.Join(boardPath, "/"), opt, bytes.NewReader(png))
|
||||
|
|
@ -126,14 +125,6 @@ func (g *GoFPDF) AddPDFPage(png []byte, boardPath []string, themeID int64, fill
|
|||
// Draw external links
|
||||
for _, shape := range shapes {
|
||||
if shape.Link != "" {
|
||||
viewboxX, err := strconv.ParseFloat(viewboxSlice[0], 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
viewboxY, err := strconv.ParseFloat(viewboxSlice[1], 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
linkX := imageX + float64(shape.Pos.X) - viewboxX - float64(shape.StrokeWidth)
|
||||
linkY := imageY + float64(shape.Pos.Y) - viewboxY - float64(shape.StrokeWidth)
|
||||
linkWidth := float64(shape.Width) + float64(shape.StrokeWidth*2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue