Class SVGImage
Used to embed SVG images in the PDF document.
It draws the path, rect, circle, ellipse, line, polyline and polygon elements, in groups or not, with their transforms, and the fill, stroke, stroke-width, stroke-dasharray, stroke-dashoffset, fill-rule, stroke-linecap, stroke-linejoin, stroke-miterlimit, opacity, fill-opacity, stroke-opacity, visibility, paint-order, clip-path and markers they have or inherit, as attributes, in a style attribute or in rules for their classes in a style element that comes before them. It draws the elements a use element names, a symbol at the size of the use, a nested svg at its x, y and viewBox, the first child of a switch that it can draw and whose systemLanguage has the language of the PDF, which is known when the image is drawn, and, of any element, one whose systemLanguage has that language or that has none, and text and tspan elements with their x, y, dx, dy, font-size, font-weight, text-anchor and dominant-baseline, in the font set with SetFont and SetBoldFont, or else in the fonts PDFjet carries, embedded: IBM Plex Sans for sans-serif, Helvetica, Arial and the like, IBM Plex Serif for serif, Times and the like, Cascadia Mono for monospace, Courier and the like, regular, semibold or bold, upright or italic, as the font-family, font-weight and font-style of the text ask. A gradient is drawn in the mean color of its stops. The width, height, viewBox and preserveAspectRatio of the svg element give the size of the image, and what is drawn outside it is cut off, as a browser does, and so is what a symbol, a marker or a nested svg draws outside its viewport, unless its overflow is visible or auto. A clipPath clips with its shapes or, when it has none, with its text elements, in those fonts, by the text rendering mode 7 of a PDF. A text cannot be in one path with other shapes, as a text object holds no path and clip paths do not add up, so the texts of a clipPath that has shapes too are left out, and the glyphs of a text clip by the nonzero rule, whatever its clip-rule. The shapes of a clipPath of several are one path, their union, by the nonzero rule, so a clip-rule of evenodd is drawn only in a clipPath of one shape: clip paths in a PDF only intersect and a path has one rule, so even-odd shapes in one union would have to be cut where they cross, and a soft mask, which PDF/A-1 forbids, is not used for it. It throws for a file that nests what it draws more than 48 deep, or that draws more than 4,000,000 path operations again, by use elements, markers and clip paths, or reads more than 20,000,000 characters of attributes again for them.
public class SVGImage : IDrawable
- Inheritance
-
SVGImage
- Implements
- Inherited Members
Constructors
SVGImage(Stream)
Used to embed SVG images in the PDF document.
public SVGImage(Stream stream)
Parameters
streamStreamthe input stream.
SVGImage(string)
Used to embed SVG images in the PDF document.
public SVGImage(string svgPath)
Parameters
svgPathstringthe path to the SVG file.
Fields
key
The destination key used by the GoTo action.
protected string key
Field Value
uri
The URI opened when the image is clicked.
protected string uri
Field Value
Methods
DrawOn(Page)
Draws this SVG image on the specified page.
public float[] DrawOn(Page page)
Parameters
pagePage
Returns
- float[]
GetHeight()
Returns the height of this SVG image.
public float GetHeight()
Returns
GetWidth()
Returns the width of this SVG image.
public float GetWidth()
Returns
ScaleBy(float)
Scales this SVG image by the specified factor.
public SVGImage ScaleBy(float factor)
Parameters
factorfloat
Returns
SetActualText(string)
Sets the actual text of this image.
public SVGImage SetActualText(string actualText)
Parameters
actualTextstring
Returns
SetAltDescription(string)
Sets the alternate description of this image.
public SVGImage SetAltDescription(string altDescription)
Parameters
altDescriptionstring
Returns
SetBoldFont(Font)
Sets the font of the bold text of the image, whose font-weight is bold or 600 or more, when a font is set with SetFont; unless set, that font draws the bold text too.
public SVGImage SetBoldFont(Font font)
Parameters
fontFontthe bold font.
Returns
- SVGImage
this SVGImage object.
SetFont(Font)
Sets the font of the text of the image, in place of the fonts PDFjet carries: for the text of a language they do not have, such as Chinese, or for a font of one's own.
public SVGImage SetFont(Font font)
Parameters
fontFontthe font.
Returns
- SVGImage
this SVGImage object.
SetGoToAction(string)
Sets the destination key for the action.
public SVGImage SetGoToAction(string key)
Parameters
keystring
Returns
SetLanguage(string)
Sets the language of this image, for example "en-US".
public SVGImage SetLanguage(string language)
Parameters
languagestring
Returns
SetLocation(float, float)
Sets the location of the top left corner of this image on the page.
public SVGImage SetLocation(float x, float y)
Parameters
Returns
SetURIAction(string)
Sets the URI for the "click box" action.
public SVGImage SetURIAction(string uri)
Parameters
uristring