‣ Rappid 2.2 released and packed with new features.
‣ Check out our other product AppMixer!

Rappid - format


This plugins imports a graph represented as an XML string in the GEXF format and makes it a JointJS graph.

The plugin contains only one function joint.format.gexf.toCellsArray(xmlString, makeElement, makeLink), where xmlString is an XML string representing a graph in GEXF format, makeElement is a function that takes an object with id, width, height and label properties and returns a JointJS shape for this node. makeLink is a function that takes an object with source and target properties and returns a JointJS link for that edge.


Include joint.format.gexf.js file into your HTML:

<script src="joint.format.gexf.js"></script>


var cells = joint.format.gexf.toCellsArray(
    function makeElement(attrs) {
        return new joint.shapes.basic.Rect({
           size: { width: attrs.width, height: attrs.height },
           attrs: { text: { text: attrs.label } }
    function makeLink(attrs) {
        return new joint.dia.Link({
            source: { id: attrs.source },
            target: { id: }



The Print plugin extends the joint.dia.Paper with the following method that, when called, prepares the paper for printing and initiates printing using the browser print wizard:

  • print([options]) - prints the paper using the browser print dialog box.

Where options is an object with the following possible values:

padding number | object the padding space on all sides of the paper area to be printed. Default is 5. The padding could be also an object with the following properties for finer grained control of the padding on each side: { paddingLeft: [number], paddingTop: [number], paddingRight: [number], paddingBottom: [number] }
size string It is for setting the actual paper print size via CSS. For example when the value is a5, it will apply rules from the .printarea-size-a5 class. It defaults to a4.
/* define paper print size via css class */
@media print and (orientation:landscape) {

    .printarea-size-a4 {
        width: 270mm !important;
        height: 168mm !important;

@media print and (orientation:portrait) {

    .printarea-size-a4 {
        width: 200mm !important;
        height: 232mm !important;


Include print.css and joint.format.print.js files into your HTML:

<link rel="stylesheet" type="text/css" href="print.css">
<script src="joint.format.print.js"></script>


$('#btn').click(function() {

If you'd like to add your custom text or logo to all the printed papers, you can use the following method in your CSS:

@media print {
    body:before {
       content: 'My Cool Company';
       top: -5mm;

This adds the text My Cool Company to the top of the printed document. For adding a logo image, just set width, height and background-image properties on the :before pseudo-element.


This plugin adds new methods to the joint.dia.Paper object for exporting paper to PNG and JPEG raster formats on the client side:

toPNG(callback [, options]) Executes the callback function with a PNG data URI representing the content of the paper as the first parameter.
toJPEG(callback [, options]) Executes the callback function with a JPEG data URI string representing the content of the paper as the first parameter.
toDataURL(callback [, options]) The general version of two previous methods. Executes the callback function with a data URI string representing the content of the paper in specified MIME type as the first parameter.

The available options are:

width number Set the width of the image in pixels.
height number Set the height of the image in pixels.
size number Size multiplicator for generating raster images in a higher resolution. It expects a string in the form of [Number] + 'x' describing how many times the image width and height should be multipicated. It defaults to '1x'.
backgroundColor string The image background color.
padding number The space between the image border and the image content. It can also be an object with left, top, right and bottom properties
type string The standard MIME type for the image format to return (only applies to toDataURL()).
quality number The quality level of a JPEG image compression in the range of 0.0 to 1.0 (only applies to toJPEG()).


Include joint.format.svg.js and joint.format.raster.js file into your HTML:

<script src="joint.format.raster.js"></script>

(Note that this plugin requires the SVG Export.)

To get the plugin to work across all modern browsers include also canvg library and its dependencies. All these files are part of the Rappid toolkit, in the Raster/lib directory:

<script src="format/Raster/lib/rgbcolor.js"></script>
<script src="format/Raster/lib/StackBlur.js"></script>
<script src="format/Raster/lib/canvg.js"></script>


paper.toPNG(function(imageData) { sendToServer(imageData); });

paper.toJPEG(function(imageData) { offerForDownload(imageData); }, {
    width: 640,
    height: 320,
    quality: 0.7


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) {


The toSVG(callback[, opt]) method takes an option object opt with the following parameters:

preserveDimensions boolean 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.
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 ignoring paper transformations (as no scale, translate or rotate is applied). It defaults to the paper content bounding box - paper.getContentBBox().
convertImagesToDataUris boolean Converts all contained images into Data URI format. It defaults to false.