iText 8.0.5 API
iText.Svg.Renderers.SvgDrawContext Class Reference

The SvgDrawContext keeps a stack of iText.Kernel.Pdf.Canvas.PdfCanvas instances, which represent all levels of XObjects that are added to the root canvas. More...

Public Member Functions

  SvgDrawContext (ResourceResolver resourceResolver, FontProvider fontProvider)
  Create an instance of the context that is used to store information when converting SVG. More...
 
virtual PdfCanvas  GetCurrentCanvas ()
  Retrieves the current top of the stack, without modifying the stack. More...
 
virtual PdfCanvas  PopCanvas ()
  Retrieves the current top of the stack, thereby taking the current item off the stack. More...
 
virtual void  PushCanvas (PdfCanvas canvas)
  Adds a iText.Kernel.Pdf.Canvas.PdfCanvas to the stack (by definition its top), for use in drawing operations. More...
 
virtual int  Size ()
  Get the current size of the stack, signifying the nesting level of the XObjects. More...
 
virtual void  AddViewPort (Rectangle viewPort)
  Adds a viewbox to the context. More...
 
virtual Rectangle  GetCurrentViewPort ()
  Get the current viewbox. More...
 
virtual Rectangle  GetRootViewPort ()
  Get the viewbox which is the root viewport for the current document. More...
 
virtual void  RemoveCurrentViewPort ()
  Remove the currently set view box. More...
 
virtual void  AddNamedObject (String name, ISvgNodeRenderer namedObject)
  Adds a named object to the draw context. More...
 
virtual ISvgNodeRenderer  GetNamedObject (String name)
  Get a named object based on its name. More...
 
virtual ResourceResolver  GetResourceResolver ()
  Gets the ResourceResolver to be used during the drawing operations. More...
 
virtual void  AddNamedObjects (IDictionary< String, ISvgNodeRenderer > namedObjects)
  * Adds a number of named object to the draw context. More...
 
virtual FontProvider  GetFontProvider ()
  Gets the FontProvider to be used during the drawing operations. More...
 
virtual FontSet  GetTempFonts ()
  Gets list of temporary fonts from @font-face. More...
 
virtual void  SetTempFonts (FontSet tempFonts)
  Sets the FontSet. More...
 
virtual bool  IsIdUsedByUseTagBefore (String elementId)
  Returns true when this id has been used before More...
 
virtual void  AddUsedId (String elementId)
  Adds an ID that has been referenced by a use element. More...
 
virtual void  RemoveUsedId (String elementId)
  Removes an ID that has been referenced by a use element. More...
 
virtual AffineTransform  GetLastTextTransform ()
  Get the text transformation that was last applied More...
 
virtual void  SetLastTextTransform (AffineTransform newTransform)
  Set the last text transformation More...
 
virtual float[]  GetTextMove ()
  Get the stored current text move More...
 
virtual void  ResetTextMove ()
  Reset the stored text move to [0f,0f] More...
 
virtual void  AddTextMove (float additionalMoveX, float additionalMoveY)
  Increment the stored text move More...
 
virtual AffineTransform  GetCurrentCanvasTransform ()
  Get the current canvas transformation More...
 
virtual SvgCssContext  GetCssContext ()
  Gets the SVG CSS context. More...
 
virtual void  SetCssContext (SvgCssContext cssContext)
  Sets the SVG CSS context. More...
 
virtual bool  PushPatternId (String patternId)
  Add pattern id to stack. More...
 
virtual void  PopPatternId ()
  Pops the last template id from the stack. More...
 
virtual void  SetPreviousElementTextMove (float[] previousElementTextMove)
 
virtual float[]  GetPreviousElementTextMove ()
 

Detailed Description

The SvgDrawContext keeps a stack of iText.Kernel.Pdf.Canvas.PdfCanvas instances, which represent all levels of XObjects that are added to the root canvas.

Constructor & Destructor Documentation

◆ SvgDrawContext()

iText.Svg.Renderers.SvgDrawContext.SvgDrawContext ( ResourceResolver  resourceResolver,
FontProvider  fontProvider 
)
inline

Create an instance of the context that is used to store information when converting SVG.

Parameters
resourceResolver instance of iText.StyledXmlParser.Resolver.Resource.ResourceResolver
fontProvider instance of iText.Layout.Font.FontProvider

Member Function Documentation

◆ AddNamedObject()

virtual void iText.Svg.Renderers.SvgDrawContext.AddNamedObject ( String  name,
ISvgNodeRenderer  namedObject 
)
inlinevirtual

Adds a named object to the draw context.

Adds a named object to the draw context. These objects can then be referenced from a different tag.

Parameters
name name of the object
namedObject object to be referenced

◆ AddNamedObjects()

virtual void iText.Svg.Renderers.SvgDrawContext.AddNamedObjects ( IDictionary< String, ISvgNodeRenderer namedObjects )
inlinevirtual

* Adds a number of named object to the draw context.

* Adds a number of named object to the draw context. These objects can then be referenced from a different tag.

Parameters
namedObjects Map containing the named objects keyed to their ID strings

◆ AddTextMove()

virtual void iText.Svg.Renderers.SvgDrawContext.AddTextMove ( float  additionalMoveX,
float  additionalMoveY 
)
inlinevirtual

Increment the stored text move

Parameters
additionalMoveX horizontal value to add
additionalMoveY vertical value to add

◆ AddUsedId()

virtual void iText.Svg.Renderers.SvgDrawContext.AddUsedId ( String  elementId )
inlinevirtual

Adds an ID that has been referenced by a use element.

Parameters
elementId referenced element ID

◆ AddViewPort()

virtual void iText.Svg.Renderers.SvgDrawContext.AddViewPort ( Rectangle  viewPort )
inlinevirtual

Adds a viewbox to the context.

Parameters
viewPort rectangle representing the current viewbox

◆ GetCssContext()

virtual SvgCssContext iText.Svg.Renderers.SvgDrawContext.GetCssContext ( )
inlinevirtual

Gets the SVG CSS context.

Returns
the SVG CSS context

◆ GetCurrentCanvas()

virtual PdfCanvas iText.Svg.Renderers.SvgDrawContext.GetCurrentCanvas ( )
inlinevirtual

Retrieves the current top of the stack, without modifying the stack.

Returns
the current canvas that can be used for drawing operations.

◆ GetCurrentCanvasTransform()

virtual AffineTransform iText.Svg.Renderers.SvgDrawContext.GetCurrentCanvasTransform ( )
inlinevirtual

Get the current canvas transformation

Returns
the iText.Kernel.Geom.AffineTransform representing the current canvas transformation

◆ GetCurrentViewPort()

virtual Rectangle iText.Svg.Renderers.SvgDrawContext.GetCurrentViewPort ( )
inlinevirtual

Get the current viewbox.

Returns
the viewbox as it is currently set

◆ GetFontProvider()

virtual FontProvider iText.Svg.Renderers.SvgDrawContext.GetFontProvider ( )
inlinevirtual

Gets the FontProvider to be used during the drawing operations.

Returns
font provider instance

◆ GetLastTextTransform()

virtual AffineTransform iText.Svg.Renderers.SvgDrawContext.GetLastTextTransform ( )
inlinevirtual

Get the text transformation that was last applied

Returns

iText.Kernel.Geom.AffineTransform representing the last text transformation

◆ GetNamedObject()

virtual ISvgNodeRenderer iText.Svg.Renderers.SvgDrawContext.GetNamedObject ( String  name )
inlinevirtual

Get a named object based on its name.

Get a named object based on its name. If the name isn't listed, this method will return null.

Parameters
name name of the object you want to reference
Returns
the referenced object

◆ GetResourceResolver()

virtual ResourceResolver iText.Svg.Renderers.SvgDrawContext.GetResourceResolver ( )
inlinevirtual

Gets the ResourceResolver to be used during the drawing operations.

Returns
resource resolver instance

◆ GetRootViewPort()

virtual Rectangle iText.Svg.Renderers.SvgDrawContext.GetRootViewPort ( )
inlinevirtual

Get the viewbox which is the root viewport for the current document.

Returns
root viewbox.

◆ GetTempFonts()

virtual FontSet iText.Svg.Renderers.SvgDrawContext.GetTempFonts ( )
inlinevirtual

Gets list of temporary fonts from @font-face.

Returns
font set instance

◆ GetTextMove()

virtual float [] iText.Svg.Renderers.SvgDrawContext.GetTextMove ( )
inlinevirtual

Get the stored current text move

Returns
[horizontal text move, vertical text move]

◆ IsIdUsedByUseTagBefore()

virtual bool iText.Svg.Renderers.SvgDrawContext.IsIdUsedByUseTagBefore ( String  elementId )
inlinevirtual

Returns true when this id has been used before

Parameters
elementId element id to check
Returns
true if id has been encountered before through a use element

◆ PopCanvas()

virtual PdfCanvas iText.Svg.Renderers.SvgDrawContext.PopCanvas ( )
inlinevirtual

Retrieves the current top of the stack, thereby taking the current item off the stack.

Returns
the current canvas that can be used for drawing operations.

◆ PopPatternId()

virtual void iText.Svg.Renderers.SvgDrawContext.PopPatternId ( )
inlinevirtual

Pops the last template id from the stack.

◆ PushCanvas()

virtual void iText.Svg.Renderers.SvgDrawContext.PushCanvas ( PdfCanvas  canvas )
inlinevirtual

Adds a iText.Kernel.Pdf.Canvas.PdfCanvas to the stack (by definition its top), for use in drawing operations.

Parameters
canvas the new top of the stack

◆ PushPatternId()

virtual bool iText.Svg.Renderers.SvgDrawContext.PushPatternId ( String  patternId )
inlinevirtual

Add pattern id to stack.

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.

Parameters
patternId pattern id
Returns

true if pattern id was not on the stack and was pushed; false if it is on the stack

◆ RemoveCurrentViewPort()

virtual void iText.Svg.Renderers.SvgDrawContext.RemoveCurrentViewPort ( )
inlinevirtual

Remove the currently set view box.

◆ RemoveUsedId()

virtual void iText.Svg.Renderers.SvgDrawContext.RemoveUsedId ( String  elementId )
inlinevirtual

Removes an ID that has been referenced by a use element.

Parameters
elementId referenced element ID

◆ ResetTextMove()

virtual void iText.Svg.Renderers.SvgDrawContext.ResetTextMove ( )
inlinevirtual

Reset the stored text move to [0f,0f]

◆ SetCssContext()

virtual void iText.Svg.Renderers.SvgDrawContext.SetCssContext ( SvgCssContext  cssContext )
inlinevirtual

Sets the SVG CSS context.

Parameters
cssContext the SVG CSS context

◆ SetLastTextTransform()

virtual void iText.Svg.Renderers.SvgDrawContext.SetLastTextTransform ( AffineTransform  newTransform )
inlinevirtual

Set the last text transformation

Parameters
newTransform last text transformation

◆ SetTempFonts()

virtual void iText.Svg.Renderers.SvgDrawContext.SetTempFonts ( FontSet  tempFonts )
inlinevirtual

Sets the FontSet.

Parameters
tempFonts font set to be used during drawing operations

◆ Size()

virtual int iText.Svg.Renderers.SvgDrawContext.Size ( )
inlinevirtual

Get the current size of the stack, signifying the nesting level of the XObjects.

Returns
the current size of the stack.