demos/Collage/fabric.js
function() {
      var markup = [
        '<?xml version="1.0" standalone="no" ?>',
          '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" ',
            '"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
          '<svg ',
            'xmlns="http://www.w3.org/2000/svg" ',
            'xmlns:xlink="http://www.w3.org/1999/xlink" ',
            'version="1.1" ',
            'width="', this.width, '" ',
            'height="', this.height, '" ',
            'xml:space="preserve">',
          '<desc>Created with Fabric.js ', fabric.version, '</desc>',
          fabric.createSVGFontFacesMarkup(this.getObjects())
      ];

      if (this.backgroundImage) {
        markup.push(
          '<image x="0" y="0" ',
            'width="', this.width,
            '" height="', this.height,
            '" preserveAspectRatio="', (this.backgroundImageStretch ? 'none' : 'defer'),
            '" xlink:href="', this.backgroundImage.src,
            '" style="opacity:', this.backgroundImageOpacity,
          '"></image>'
        );
      }

      for (var i = 0, objects = this.getObjects(), len = objects.length; i < len; i++) {
        markup.push(objects[i].toSVG());
      }
      markup.push('</svg>');

      return markup.join('');
    }
function() {
      var markup = [
        '<?xml version="1.0" standalone="no" ?>',
          '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" ',
            '"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
          '<svg ',
            'xmlns="http://www.w3.org/2000/svg" ',
            'xmlns:xlink="http://www.w3.org/1999/xlink" ',
            'version="1.1" ',
            'width="', this.width, '" ',
            'height="', this.height, '" ',
            'xml:space="preserve">',
          '<desc>Created with Fabric.js ', fabric.version, '</desc>',
          fabric.createSVGFontFacesMarkup(this.getObjects())
      ];

      if (this.backgroundImage) {
        markup.push(
          '<image x="0" y="0" ',
            'width="', this.width,
            '" height="', this.height,
            '" preserveAspectRatio="', (this.backgroundImageStretch ? 'none' : 'defer'),
            '" xlink:href="', this.backgroundImage.src,
            '" style="opacity:', this.backgroundImageOpacity,
          '"></image>'
        );
      }

      for (var i = 0, objects = this.getObjects(), len = objects.length; i < len; i++) {
        markup.push(objects[i].toSVG());
      }
      markup.push('</svg>');

      return markup.join('');
    }
function ( ) { var markup = [ '<?xml version="1.0" standalone="no" ?>' , '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" ' , '"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' , '<svg ' , 'xmlns="http://www.w3.org/2000/svg" ' , 'xmlns:xlink="http://www.w3.org/1999/xlink" ' , 'version="1.1" ' , 'width="' , this . width , '" ' , 'height="' , this . height , '" ' , 'xml:space="preserve">' , '<desc>Created with Fabric.js ' , fabric . version , '</desc>' , fabric . createSVGFontFacesMarkup ( this . getObjects ( ) ) ] ; if ( this . backgroundImage ) { markup . push ( '<image x="0" y="0" ' , 'width="' , this . width , '" height="' , this . height , '" preserveAspectRatio="' , ( this . backgroundImageStretch ? 'none' : 'defer' ) , '" xlink:href="' , this . backgroundImage . src , '" style="opacity:' , this . backgroundImageOpacity , '"></image>' ) ; } for ( var i = 0 , objects = this . getObjects ( ) , len = objects . length ; i < len ; i ++ ) { markup . push ( objects [ i ] . toSVG ( ) ) ; } markup . push ( '</svg>' ) ; return markup . join ( '' ) ; }
Returns SVG representation of canvas
@function
@method toSVG
@return {String}
Returns SVG representation of canvas