SvgImage

Inheritance: java.lang.Object, com.groupdocs.editor.htmlcss.resources.images.vector.VectorImageResourceBase

public final class SvgImage extends VectorImageResourceBase

Represents one vector image in SVG (Scalable Vector Graphics) format with its metadata and additional methods

Constructors

Constructor Description
SvgImage(String name, String content) Creates new SvgImage instance from content, represented as usual string, and with specified name
SvgImage(String name, InputStream binaryContent) Creates new SvgImage instance from content, represented as byte stream, and with specified name

Methods

Method Description
isValid(String content) Performs a surface check whether specified textual XML-compliant content represents a SVG image
getType() Returns ImageType.Svg
getByteContent() Returns a content of this SVG image as a binary stream
getTextContent() Returns a content of this SVG image as a plain text (in XML format)
getXmlContent() Returns a content of this SVG image int its original XML-compliant textual form
save(String fullPathToFile) Saves this SVG image to the file
saveToPng(OutputStream outputPngContent) Saves this vector SVG image into raster PNG image
dispose() Disposes this raster image, disposing its content and making most methods and properties non-working

SvgImage(String name, String content)

public SvgImage(String name, String content)

Creates new SvgImage instance from content, represented as usual string, and with specified name

Parameters:

Parameter Type Description
name java.lang.String Name of the SVG image. Cannot be null, empty or whitespaces.
content java.lang.String Content as a usual string, which contains a valid XML-compliant content of SVG image. Cannot be null, empty or whitespaces. If it is not a SVG content, exception will be thrown.

SvgImage(String name, InputStream binaryContent)

public SvgImage(String name, InputStream binaryContent)

Creates new SvgImage instance from content, represented as byte stream, and with specified name

Parameters:

Parameter Type Description
name java.lang.String Name of the SVG image. Cannot be null, empty or whitespaces.
binaryContent java.io.InputStream Content as byte stream. Reading begins from original position. Cannot be null. Should be readable and seekable. If this instance will be disposed, this stream will be disposed too.

isValid(String content)

public static boolean isValid(String content)

Performs a surface check whether specified textual XML-compliant content represents a SVG image

Parameters:

Parameter Type Description
content java.lang.String XML content of an SVG image as simple text, not a base64-encoded content

Returns: boolean - True if specified string can be treated as valid SVG at first look, false if it is not SVG for sure

getType()

public ImageType getType()

Returns ImageType.Svg

Returns: ImageType -

getByteContent()

public InputStream getByteContent()

Returns a content of this SVG image as a binary stream

Returns: java.io.InputStream -

getTextContent()

public String getTextContent()

Returns a content of this SVG image as a plain text (in XML format)

Returns: java.lang.String -

getXmlContent()

public final String getXmlContent()

Returns a content of this SVG image int its original XML-compliant textual form

Returns: java.lang.String -

save(String fullPathToFile)

public void save(String fullPathToFile)

Saves this SVG image to the file

Parameters:

Parameter Type Description
fullPathToFile java.lang.String Full path to the file, which will be created (if it doesn’t exist) or overwritten (if exists) with the content of this SVG image

saveToPng(OutputStream outputPngContent)

public void saveToPng(OutputStream outputPngContent)

Saves this vector SVG image into raster PNG image

Parameters:

Parameter Type Description
outputPngContent java.io.OutputStream Output stream, into which the content of PNG image will be written. Cannot be NULL and should be writable.

dispose()

public void dispose()

Disposes this raster image, disposing its content and making most methods and properties non-working