Class SVGScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("svg")
    @Singleton
    public class SVGScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Utilities for working with SVG images.
    Since:
    8.0M1
    Version:
    $Id: 828b7c8df8b2f726dbbe5d9dca523e555f4d1eec $
    • Constructor Detail

      • SVGScriptService

        public SVGScriptService()
    • Method Detail

      • rasterizeToTemporaryResource

        public ExtendedURL rasterizeToTemporaryResource​(String content)
        Rasterize an image as PNG into a temporary resource belonging to the current document, accessible through the "tmp" resource URL handler.
        Parameters:
        content - the SVG image
        Returns:
        URL pointing to the temporary resource where the PNG is stored
      • rasterizeToTemporaryResource

        public ExtendedURL rasterizeToTemporaryResource​(String content,
                                                        int width,
                                                        int height)
        Rasterize an image as PNG into a temporary resource belonging to the current document, accessible through the "tmp" resource URL handler.
        Parameters:
        content - the SVG image
        width - the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size is used
        height - the desired height of the raster image, in pixels; if 0 or a negative number, the image's native size is used
        Returns:
        URL pointing to the temporary resource where the PNG is stored
      • rasterizeToTemporaryResource

        public ExtendedURL rasterizeToTemporaryResource​(String content,
                                                        DocumentReference targetContext)
        Rasterize an image as PNG into a temporary resource belonging to the current document, accessible through the "tmp" resource URL handler.
        Parameters:
        content - the SVG image
        targetContext - the document which will "own" the new temporary resource
        Returns:
        URL pointing to the temporary resource where the PNG is stored
      • rasterizeToTemporaryResource

        public ExtendedURL rasterizeToTemporaryResource​(String content,
                                                        int width,
                                                        int height,
                                                        DocumentReference targetContext)
        Rasterize an image as PNG as into temporary resource belonging to the current document, accessible through the "tmp" resource URL handler.
        Parameters:
        content - the SVG image
        width - the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size is used
        height - the desired height of the raster image, in pixels; if 0 or a negative number, the image's native size is used
        targetContext - the document which will "own" the new temporary resource
        Returns:
        URL pointing to the temporary resource where the PNG is stored
      • rasterizeToResponse

        public boolean rasterizeToResponse​(String content)
        Rasterize an image as PNG into the current response.
        Parameters:
        content - the SVG image
        Returns:
        true if the image was successfully rasterized and written to the response, false in case of exceptions
      • rasterizeToResponse

        public boolean rasterizeToResponse​(String content,
                                           int width,
                                           int height)
        Rasterize an image as PNG into the current response.
        Parameters:
        content - the SVG image
        width - the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size is used
        height - the desired height of the raster image, in pixels; if 0 or a negative number, the image's native size is used
        Returns:
        true if the image was successfully rasterized and written to the response, false in case of exceptions