SVG Rasterizing API
APIs to rasterize SVG images |
Type | JAR |
Category | API |
Developed by | |
Active Installs | 0 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Compatibility | In XWiki 15.6, the SVG Rasterizing API has been removed from XWiki Standard and moved as a Contrib extension (released as version 15.6). Also, if you were using the Java API, you'll need to change the packages from org.xwiki.platform.svg to org.xwiki.contrib.svg. |
Table of contents
Description
Java API
{
/**
* Rasterize an image as PNG into a temporary file.
*
* @param content the SVG image
* @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size
* is used
* @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native
* size is used
* @return the file where the PNG is stored
* @throws IOException if temporary files can't be accessed
*/
File rasterizeToTemporaryFile(String content, int width, int height) throws IOException;
/**
* Rasterize an image as PNG as a temporary resource belonging to the current document, which can be accessed with
* the /temp/ action.
*
* @param content the SVG image
* @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size
* is used
* @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native
* size is used
* @return the temporary resource where the PNG is stored
* @throws IOException if temporary files can't be accessed
*/
TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height) throws IOException;
/**
* Rasterize an image as PNG as a temporary resource belonging to the specified document, which can be accessed with
* the /temp/ action.
*
* @param content the SVG image
* @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size
* is used
* @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native
* size is used
* @param targetContext the document which will "own" the new temporary resource
* @return the temporary resource where the PNG is stored
* @throws IOException if temporary files can't be accessed
*/
TemporaryResourceReference rasterizeToTemporaryResource(String content, int width, int height,
DocumentReference targetContext) throws IOException;
/**
* Rasterize an image as PNG into the current response.
*
* @param content the SVG image
* @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size
* is used
* @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native
* size is used
* @throws IOException if writing the response fails
*/
void rasterizeToResponse(String content, int width, int height) throws IOException;
}
Scripting API
* Rasterize an image as PNG as a temporary resource belonging to the current document, which can be accessed with
* the /temp/ action.
*
* @param content the SVG image
* @return URL pointing to the temporary resource where the PNG is stored
*/
public ExtendedURL rasterizeToTemporaryResource(String content)
/**
* Rasterize an image as PNG as a temporary resource belonging to the current document, which can be accessed with
* the /temp/ action.
*
* @param content the SVG image
* @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size
* is used
* @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native
* size is used
* @return URL pointing to the temporary resource where the PNG is stored
*/
public ExtendedURL rasterizeToTemporaryResource(String content, int width, int height)
/**
* Rasterize an image as PNG as a temporary resource belonging to the current document, which can be accessed with
* the /temp/ action.
*
* @param content the SVG image
* @param targetContext the document which will "own" the new temporary resource
* @return URL pointing to the temporary resource where the PNG is stored
*/
public ExtendedURL rasterizeToTemporaryResource(String content, DocumentReference targetContext)
/**
* Rasterize an image as PNG as a temporary resource belonging to the current document, which can be accessed with
* the /temp/ action.
*
* @param content the SVG image
* @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size
* is used
* @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native
* size is used
* @param targetContext the document which will "own" the new temporary resource
* @return URL pointing to the temporary resource where the PNG is stored
*/
public ExtendedURL rasterizeToTemporaryResource(String content, int width, int height,
DocumentReference targetContext)
/**
* Rasterize an image as PNG into the current response.
*
* @param content the SVG image
* @return {@code true} if the image was successfully rasterized and written to the response, {@code false} in case
* of exceptions
*/
public boolean rasterizeToResponse(String content)
/**
* Rasterize an image as PNG into the current response.
*
* @param content the SVG image
* @param width the desired width of the raster image, in pixels; if 0 or a negative number, the image's native size
* is used
* @param height the desired height of the raster image, in pixels; if 0 or a negative number, the image's native
* size is used
* @return {@code true} if the image was successfully rasterized and written to the response, {@code false} in case
* of exceptions
*/
public boolean rasterizeToResponse(String content, int width, int height)
}
For example from Velocity:
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Dependencies
Dependencies for this extension (org.xwiki.contrib:svg-rasterizer 15.6):
- org.apache.xmlgraphics:batik-transcoder 1.16
- org.apache.xmlgraphics:batik-codec 1.16
- org.apache.xmlgraphics:xmlgraphics-commons 2.8
- org.xwiki.commons:xwiki-commons-component-api 14.10
- org.xwiki.commons:xwiki-commons-environment-api 14.10
- org.xwiki.commons:xwiki-commons-script 14.10
- org.xwiki.platform:xwiki-platform-container-api 14.10
- org.xwiki.platform:xwiki-platform-url-api 14.10
- org.xwiki.platform:xwiki-platform-resource-api 14.10
- org.xwiki.platform:xwiki-platform-resource-temporary 14.10
- org.xwiki.platform:xwiki-platform-model-api 14.10
- org.xwiki.platform:xwiki-platform-container-servlet 14.10
- commons-io:commons-io 2.11.0
- org.slf4j:slf4j-api 1.7.36