...

Package svg

Overview ▾

type Command

Command is a representation of an SVG path command and its parameters.

type Command struct {
    Symbol string
    Params []float64
}

type GraphicSVG

GraphicSVG element represents SVG instances.

type GraphicSVG struct {
    // ViewBox represents viewBox value of element.
    ViewBox struct{ X, Y, W, H float64 }

    // Name of element.
    Name string

    // Attributes of element.
    Attributes map[string]string

    // Children elements.
    Children []*GraphicSVG

    // Content contains text value of element.
    Content string

    // Style element style attribute.
    Style *GraphicSVGStyle

    // Width of element.
    Width float64

    // Height of element.
    Height float64
    // contains filtered or unexported fields
}

func ParseFromFile

func ParseFromFile(path string) (*GraphicSVG, error)

ParseFromFile creates a GraphicSVG instance from file.

func ParseFromStream

func ParseFromStream(source io.Reader) (*GraphicSVG, error)

ParseFromStream creates a GraphicSVG instance from SVG stream input.

func ParseFromString

func ParseFromString(svgStr string) (*GraphicSVG, error)

ParseFromString creates a GraphicSVG instance from string SVG.

func (*GraphicSVG) Decode

func (g *GraphicSVG) Decode(decoder *xml.Decoder) error

Decode decodes the child elements of element.

func (*GraphicSVG) SetScaling

func (g *GraphicSVG) SetScaling(xFactor, yFactor float64)

SetScaling sets scaling value for graphic SVG and maintain the aspect ratio.

func (*GraphicSVG) ToContentCreator

func (g *GraphicSVG) ToContentCreator(cc *contentstream.ContentCreator, res *model.PdfPageResources, scaleX, scaleY, translateX, translateY float64) *contentstream.ContentCreator

ToContentCreator convert SVG and add elements contentstream then returns `contentstream.ContentCreator`.

type GraphicSVGStyle

GraphicSVGStyle represents style attributes for `GraphicSVG`.

type GraphicSVGStyle struct {
    FillColor   string
    StrokeColor string
    StrokeWidth float64
    FillOpacity float64
}

type Path

Path is a collection of all the subpaths in 'd' attribute.

type Path struct {
    Subpaths []*Subpath
}

type Subpath

Subpath is a collection of Commands, beginning with moveto command and usually ending with closepath command.

type Subpath struct {
    Commands []*Command
}