draw2d/draw2dsvg/fileutil.go
Drahoslav 96883adea4 Initial commit for svg context
Satisfy draw2dc.GrapghicContext using empty methods
2017-12-16 19:26:34 +01:00

24 lines
No EOL
508 B
Go

package draw2dsvg
import (
"os"
"bytes"
"errors"
svgo "github.com/ajstarks/svgo/float"
)
func SaveToSvgFile(filePath string, svg *svgo.SVG) error {
f, err := os.Create(filePath)
if err != nil {
return err
}
defer f.Close()
if b, ok := svg.Writer.(*bytes.Buffer); ok {
bytes.NewBuffer(b.Bytes()).WriteTo(f) // clone buffer to make multiple writes possible
} else {
return errors.New("Svg has not been not created from with NewSvg (dow not have byte.Buffer as its Writer)")
}
return nil
}