Skip to content

PdfSvg class

View as Markdown

Namespace: PdfNetStack.Drawing
Assembly: PdfNetStack.dll
Package: PdfNetStack

An SVG drawing, placed as vector graphics: it stays sharp at any zoom and its text stays text. Each drawing is written once per document and reused wherever it is placed. Supported: shapes, paths, groups, use and symbol, nested viewports, solid colors and linear and radial gradients, clip paths, opacity, text in the standard fonts, embedded JPEG and PNG images, and style sheets with type, class and id selectors. Not supported: filters, masks, patterns, external references and animation.

public sealed class PdfSvg

Inheritance

object ← PdfSvg

PdfSvg logo = PdfSvg.Load("logo.svg");
using PdfGraphics g = page.CreateGraphics();
g.DrawSvg(logo, 40, 40, 120, 40);

Height in points at the drawing’s own size.

public double Height { get; }

double

Width in points at the drawing’s own size, CSS pixels at 96 per inch.

public double Width { get; }

double

Loads an SVG file, UTF-8 unless it starts with a byte order mark.

public static PdfSvg Load(string path)

path string

PdfSvg

FormatException

The file is not SVG.

Loads SVG from a stream, up to 32 MiB.

public static PdfSvg Load(Stream stream)

stream Stream

PdfSvg

FormatException

The data is not SVG.

Loads SVG from bytes, UTF-8 unless they start with a byte order mark.

public static PdfSvg Load(byte[] data)

data byte[]

PdfSvg

FormatException

The data is not SVG.

Parses SVG markup.

public static PdfSvg Parse(string svg)

svg string

PdfSvg

FormatException

The text has no svg root element.