Class SvgImageXObject


public class SvgImageXObject extends PdfFormXObject
A wrapper for Form XObject for SVG images.
  • Constructor Details

    • SvgImageXObject

      public SvgImageXObject (Rectangle bBox, ISvgProcessorResult result, ResourceResolver resourceResolver)
      Creates a new instance of Form XObject for the SVG image.
      Parameters:
      bBox - the form XObject’s bounding box.
      result - processor result containing the SVG information.
      resourceResolver - ResourceResolver for the SVG image.
    • SvgImageXObject

      public SvgImageXObject (ISvgProcessorResult result, SvgDrawContext svgContext, float em, PdfDocument pdfDocument)
      Creates a new instance of Form XObject for the relative sized SVG image.
      Parameters:
      result - processor result containing the SVG information
      svgContext - the svg draw context
      em - em value in pt
      pdfDocument - pdf that shall contain the SVG image, can be null
  • Method Details

    • setIsCreatedByImg

      public void setIsCreatedByImg (boolean isCreatedByImg)
      Set if SVG image is created from HTML img tag context
      Parameters:
      isCreatedByImg - true if object is created from HTML img tag, false otherwise
    • isCreatedByImg

      public boolean isCreatedByImg()
      Check if SVG image is created from HTML img tag context
      Returns:
      true if object is created from HTML img tag, false otherwise
    • setIsCreatedByObject

      public void setIsCreatedByObject (boolean isCreatedByObject)
      Set if SVG image is created from HTML object tag context
      Parameters:
      isCreatedByObject - true if object is created from HTML object tag, false otherwise
    • isCreatedByObject

      public boolean isCreatedByObject()
      Check if SVG image is created from HTML object tag context
      Returns:
      true if object is created from HTML object tag, false otherwise
    • isRelativeSized

      public boolean isRelativeSized()
      If the SVG image is relative sized. This information is used during image layouting to resolve it's relative size.
      Overrides:
      isRelativeSized in class PdfFormXObject
      Returns:
      true if the SVG image is relative sized, false otherwise
      See Also:
    • getResult

      public ISvgProcessorResult getResult()
      Returns processor result containing the SVG information.
      Returns:
      {ISvgProcessorResult} processor result.
    • getResourceResolver

      @Deprecated public ResourceResolver getResourceResolver()
      Deprecated.
      not used anymore
      Returns resource resolver for the SVG image.
      Returns:
      ResourceResolver instance
    • generate

      public void generate (PdfDocument document)
      Processes xObject before first image generation to avoid drawing it twice or more. It allows to reuse the same Form XObject multiple times.
      Parameters:
      document - pdf that shall contain the SVG image, can be null if constructor SvgImageXObject(ISvgProcessorResult, SvgDrawContext, float, PdfDocument) was used
    • updateBBox

      public void updateBBox (float areaWidth, float areaHeight)
      Updated XObject BBox for relative sized SVG image.
      Parameters:
      areaWidth - the area width where SVG image will be drawn
      areaHeight - the area height where SVG image will be drawn
    • getElementWidth

      public UnitValue getElementWidth()
      Gets the SVG element width.
      Returns:
      the SVG element width
    • getElementHeight

      public UnitValue getElementHeight()
      Gets the SVG element height.
      Returns:
      the SVG element height