Package org.xwiki.platform.svg.script
Class SVGScriptService
- java.lang.Object
-
- org.xwiki.platform.svg.script.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 Summary
Constructors Constructor Description SVGScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
rasterizeToResponse(String content)
Rasterize an image as PNG into the current response.boolean
rasterizeToResponse(String content, int width, int height)
Rasterize an image as PNG into the current response.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.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.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.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.
-
-
-
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 imagewidth
- the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size is usedheight
- 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 imagetargetContext
- 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 imagewidth
- the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size is usedheight
- the desired height of the raster image, in pixels; if 0 or a negative number, the image's native size is usedtargetContext
- 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 imagewidth
- the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size is usedheight
- 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
-
-