🎉 JointJS has new documentation! 🥳
This plugins adds two new methods to the joint.dia.Paper
object:
toSVG(callback[, opt])
- Converts the content of the paper to an SVG string and calls the callback with the SVG string as the first parameter.openAsSVG()
- Opens a new window with SVG representing the content of the paper.Include joint.format.svg.js
file into your HTML:
<script src="joint.format.svg.js"></script>
paper.toSVG(function(svgString) {
sendToServer(svgString);
offerForDownload(svgString);
});
The toSVG(callback[, opt])
method takes an option object opt
with the following parameters:
preserveDimensions | boolean | object | By default, the resulting SVG document has set width and height to 100%. If you'd like to have the dimensions to
be set to the actual content width and height, set preserveDimensions to true .
An object with width and height properties can be also used here if you need to define the export size explicitely.
|
area | g.Rect | An area, that the resulting SVG should display. The value is an object, which contains x ,y ,width and height , describing the origin and the size of a rectangular area on the paper in the local coordinates. It defaults to the paper content bounding box - paper.getContentBBox() transformed into the local coordinates.
|
convertImagesToDataUris | boolean | Converts all contained images into Data URI format. It defaults to false . |
useComputedStyles | boolean |
When set to
When set to
|
stylesheet | string |
A stylesheet (as string) can be provided and appended to the resulting SVG export.
It defaults to |
beforeSerialize(SVGDocument, paper) | function | A function called before the XML serialization. It may be used to modify the exported SVG before it is converted to a string. The function can also return a new SVGDocument.
|