dsdsdsdsd
dsdsdsdsd

Reputation: 2962

How to get width of imported svg file using fabricjs

I am importing an svg from Corel ... the Corel stage is huge, about 3000x3000px. The svg created by Corel includes the w/h of the stage in the <svg> element:

<svg ... width="2479px" height="3504px" ... >

I import that svg into html via fabricjs:

$("#loadSVG")
  .click( function()
            { fabric.loadSVGFromURL( gvs_svgSrc                             , 
                                     function( A , B ){ callback( A , B ) } ,
                                     function( M , N ){ reviver ( M , N ) } 
                                   );
            });

Now I would like to scale my fabric objects according to the relationship between my canvas w/h vs the svg w/h.

QUESTION: how can I get the <svg> w/h attributes using fabricjs?

NOTE: I suppose I could do this with javascript/jquery, but I would like to think that fabric already has this information stored in it.

NOTE: I should mention that the vector shapes coming from Corel are broken up into many different groups inside fabric's reviver function. In other words they are not all in ONE group (which would allow me to query the group's w/h.

Upvotes: 0

Views: 810

Answers (1)

Keylan
Keylan

Reputation: 325

In your callback function (the second argument), B is an object with the svg canvas width and height properties.

Upvotes: 1

Related Questions