Class SvgDrawContext
The SvgDrawContext keeps a stack of PdfCanvas instances, which represent all levels of XObjects that are added to the root canvas.
public class SvgDrawContext
- Inheritance
-
SvgDrawContext
- Inherited Members
Constructors
SvgDrawContext(ResourceResolver, FontProvider)
Create an instance of the context that is used to store information when converting SVG.
public SvgDrawContext(ResourceResolver resourceResolver, FontProvider fontProvider)
Parameters
resourceResolver
ResourceResolverinstance of ResourceResolver
fontProvider
FontProviderinstance of FontProvider
Methods
AddNamedObject(string, ISvgNodeRenderer)
Adds a named object to the draw context.
public virtual void AddNamedObject(string name, ISvgNodeRenderer namedObject)
Parameters
name
stringname of the object
namedObject
ISvgNodeRendererobject to be referenced
Remarks
Adds a named object to the draw context. These objects can then be referenced from a different tag.
AddNamedObjects(IDictionary<string, ISvgNodeRenderer>)
- Adds a number of named object to the draw context.
public virtual void AddNamedObjects(IDictionary<string, ISvgNodeRenderer> namedObjects)
Parameters
namedObjects
IDictionary<string, ISvgNodeRenderer>Map containing the named objects keyed to their ID strings
Remarks
- Adds a number of named object to the draw context. These objects can then be referenced from a different tag.
AddTextMove(float, float)
Increment the stored text move
public virtual void AddTextMove(float additionalMoveX, float additionalMoveY)
Parameters
AddUsedId(string)
Adds an ID that has been referenced by a use element.
public virtual void AddUsedId(string elementId)
Parameters
elementId
stringreferenced element ID
AddViewPort(Rectangle)
Adds a viewbox to the context.
public virtual void AddViewPort(Rectangle viewPort)
Parameters
viewPort
Rectanglerectangle representing the current viewbox
GetCssContext()
Gets the SVG CSS context.
public virtual SvgCssContext GetCssContext()
Returns
- SvgCssContext
the SVG CSS context
GetCurrentCanvas()
Retrieves the current top of the stack, without modifying the stack.
public virtual PdfCanvas GetCurrentCanvas()
Returns
- PdfCanvas
the current canvas that can be used for drawing operations.
GetCurrentCanvasTransform()
Get the current canvas transformation
public virtual AffineTransform GetCurrentCanvasTransform()
Returns
- AffineTransform
the AffineTransform representing the current canvas transformation
GetCurrentViewPort()
Get the current viewbox.
public virtual Rectangle GetCurrentViewPort()
Returns
- Rectangle
the viewbox as it is currently set
GetFontProvider()
Gets the FontProvider to be used during the drawing operations.
public virtual FontProvider GetFontProvider()
Returns
- FontProvider
font provider instance
GetLastTextTransform()
Get the text transformation that was last applied
public virtual AffineTransform GetLastTextTransform()
Returns
- AffineTransform
AffineTransform representing the last text transformation
GetNamedObject(string)
Get a named object based on its name.
public virtual ISvgNodeRenderer GetNamedObject(string name)
Parameters
name
stringname of the object you want to reference
Returns
- ISvgNodeRenderer
the referenced object
Remarks
Get a named object based on its name. If the name isn't listed, this method will return null.
GetPreviousElementTextMove()
public virtual float[] GetPreviousElementTextMove()
Returns
- float[]
GetResourceResolver()
Gets the ResourceResolver to be used during the drawing operations.
public virtual ResourceResolver GetResourceResolver()
Returns
- ResourceResolver
resource resolver instance
GetRootViewPort()
Get the viewbox which is the root viewport for the current document.
public virtual Rectangle GetRootViewPort()
Returns
- Rectangle
root viewbox.
GetTempFonts()
Gets list of temporary fonts from @font-face.
public virtual FontSet GetTempFonts()
Returns
- FontSet
font set instance
GetTextMove()
Get the stored current text move
public virtual float[] GetTextMove()
Returns
- float[]
[horizontal text move, vertical text move]
IsIdUsedByUseTagBefore(string)
Returns true when this id has been used before
public virtual bool IsIdUsedByUseTagBefore(string elementId)
Parameters
elementId
stringelement id to check
Returns
- bool
true if id has been encountered before through a use element
PopCanvas()
Retrieves the current top of the stack, thereby taking the current item off the stack.
public virtual PdfCanvas PopCanvas()
Returns
- PdfCanvas
the current canvas that can be used for drawing operations.
PopPatternId()
Pops the last template id from the stack.
public virtual void PopPatternId()
PushCanvas(PdfCanvas)
Adds a PdfCanvas to the stack (by definition its top), for use in drawing operations.
public virtual void PushCanvas(PdfCanvas canvas)
Parameters
canvas
PdfCanvasthe new top of the stack
PushPatternId(string)
Add pattern id to stack.
public virtual bool PushPatternId(string patternId)
Parameters
patternId
stringpattern id
Returns
Remarks
Add pattern id to stack. Check if the id is already in the stack. If it is, then return false and not add, if it is not - add and return true.
RemoveCurrentViewPort()
Remove the currently set view box.
public virtual void RemoveCurrentViewPort()
RemoveUsedId(string)
Removes an ID that has been referenced by a use element.
public virtual void RemoveUsedId(string elementId)
Parameters
elementId
stringreferenced element ID
ResetTextMove()
Reset the stored text move to [0f,0f]
public virtual void ResetTextMove()
SetCssContext(SvgCssContext)
Sets the SVG CSS context.
public virtual void SetCssContext(SvgCssContext cssContext)
Parameters
cssContext
SvgCssContextthe SVG CSS context
SetLastTextTransform(AffineTransform)
Set the last text transformation
public virtual void SetLastTextTransform(AffineTransform newTransform)
Parameters
newTransform
AffineTransformlast text transformation
SetPreviousElementTextMove(float[])
public virtual void SetPreviousElementTextMove(float[] previousElementTextMove)
Parameters
previousElementTextMove
float[]
SetTempFonts(FontSet)
Sets the FontSet.
public virtual void SetTempFonts(FontSet tempFonts)
Parameters
tempFonts
FontSetfont set to be used during drawing operations
Size()
Get the current size of the stack, signifying the nesting level of the XObjects.
public virtual int Size()
Returns
- int
the current size of the stack.