🎉 JointJS has new documentation! 🥳
This plugin 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. The second parameter is an optional error in the case something happened during the processing.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, error) {
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 explicitly. |
area | g.Rect | An area which should be displayed in the resulting raster image. The value is an object with x , y , width and height properties, describing the origin and 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.
|
fillFormControls | boolean | Fill in the values of all form controls (input, select, textarea) so that they are displayed in the export (form controls can be part of the export if they are inserted via foreignObject). It defaults to true . |