And if anyone wants to convert SVG to Canvas without a library, you can use
this method. (*Only issue I faced here is that it doesn't have a method to
get external styles*)

var svgString = new
XMLSerializer().serializeToString(document.querySelector('svg'));

var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var DOMURL = self.URL || self.webkitURL || self;
var img = new Image();
var svg = new Blob([svgString], {type: "image/svg+xml;charset=utf-8"});
var url = DOMURL.createObjectURL(svg);
img.onload = function() {
    ctx.drawImage(img, 0, 0);
    var png = canvas.toDataURL("image/png");
    document.querySelector('#png-container').innerHTML = '<img src="'+png+'"/>';
    DOMURL.revokeObjectURL(png);
};
img.src = url;

Cheers!
Jerad


On Fri, Jan 30, 2015 at 11:39 AM, Jerad Rutnam <je...@wso2.com> wrote:

> Hi Dakshika,
>
> Thanks for this. I tried *svgenie *[1] library earlier, which is depends
> on *canvg.js. *But it didn't work for me. Anyway didn't try it pure, so
> i'll give a try and send you an update.
>
> [1] - https://github.com/Causata/svgenie
>
> Regards,
> Jerad
>
> On Fri, Jan 30, 2015 at 10:20 AM, Dakshika Jayathilaka <daksh...@wso2.com>
> wrote:
>
>> Hi,
>>
>> I found simple lib to convert SVG to Canvas.
>>
>> https://github.com/gabelerner/canvg
>>
>> Then you can export it as a image or can convert to PDF as wel..
>>
>> Regards,
>>
>> *Dakshika Jayathilaka*
>> Software Engineer
>> WSO2, Inc.
>> lean.enterprise.middleware
>> 0771100911
>>
>> On Mon, Jan 26, 2015 at 10:44 AM, Jerad Rutnam <je...@wso2.com> wrote:
>>
>>> Hi Dimuthu,
>>>
>>> Thanks, I'll check this and give you an update.
>>>
>>> Regards,
>>> Jerad
>>>
>>> On Mon, Jan 26, 2015 at 10:30 AM, Dimuthu De Lanerolle <
>>> dimut...@wso2.com> wrote:
>>>
>>>> Hi Jerad,
>>>>
>>>> I think you can try apache batik-transcoder dependency for this [1]
>>>>
>>>> [1]
>>>> https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleSVG2PDF.java
>>>>
>>>>
>>>>
>>>> Regards
>>>>
>>>> On Mon, Jan 26, 2015 at 8:40 AM, Jerad Rutnam <je...@wso2.com> wrote:
>>>>
>>>>> Hi Sagara,
>>>>>
>>>>> Currently i'm working on the feature "fit to screen". Once that and
>>>>> other critical issues are fixed, ill do a research on this.
>>>>>
>>>>> Regards,
>>>>> Jerad
>>>>>
>>>>> On Thu, Jan 22, 2015 at 8:27 AM, Jerad Rutnam <je...@wso2.com> wrote:
>>>>>
>>>>>> Hi Vanjikumaran,
>>>>>>
>>>>>> We have developed a Dependency Graph feature for G-Reg using D3. And
>>>>>> we are thinking of having a function to export the graph to print. So
>>>>>> thought something like exporting to .PDF would be nice.
>>>>>>
>>>>>> Thanks,
>>>>>> Jerad
>>>>>>
>>>>>> On Wed, Jan 21, 2015 at 7:20 PM, Vanjikumaran Sivajothy <
>>>>>> va...@wso2.com> wrote:
>>>>>>
>>>>>>> AFAIK, Wso2 products does not use any such feature.
>>>>>>>
>>>>>>> However, What is your exact requirement and use case?
>>>>>>>
>>>>>>> On Wed, Jan 21, 2015 at 10:15 AM, Jerad Rutnam <je...@wso2.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Are we using any SVG to PDF convert library in our products? Or is
>>>>>>>> there anyway I can achieve this? ex:-
>>>>>>>> http://d3export.housegordon.org/
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Jerad
>>>>>>>> --
>>>>>>>> *Jerad Rutnam*
>>>>>>>> *Software Engineer - UI*
>>>>>>>>
>>>>>>>> WSO2 Inc.
>>>>>>>> lean | enterprise | middleware
>>>>>>>> M : +94 77 959 1609 | E : je...@wso2.com | W : www.wso2.com
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dev mailing list
>>>>>>>> Dev@wso2.org
>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Sivajothy Vanjikumaran
>>>>>>> *Senior Software Engineer*
>>>>>>> *Integration Technologies Team*
>>>>>>> *WSO2 Inc. http://wso2.com <http://wso2.com/>*
>>>>>>> *Mobile:(+94)777219209*
>>>>>>> [image: Facebook] <https://www.facebook.com/vanjikumaran> [image:
>>>>>>> Twitter] <https://twitter.com/vanjikumaran> [image: LinkedIn]
>>>>>>> <http://www.linkedin.com/pub/vanjikumaran-sivajothy/25/b31/293> [image:
>>>>>>> Blogger] <http://vanjikumaran.blogspot.com/> [image: SlideShare]
>>>>>>> <http://www.slideshare.net/vanjikumaran>
>>>>>>>
>>>>>>> This communication may contain privileged or other
>>>>>>> confidential information and is intended exclusively for the 
>>>>>>> addressee/s.
>>>>>>> If you are not the intended recipient/s, or believe that you may
>>>>>>> have received this communication in error, please reply to the
>>>>>>> sender indicating that fact and delete the copy you received and in
>>>>>>> addition, you should not print, copy, re-transmit, disseminate, or
>>>>>>> otherwise use the information contained in this communication.
>>>>>>> Internet communications cannot be guaranteed to be timely, secure, error
>>>>>>> or virus-free. The sender does not accept liability for any errors
>>>>>>> or omissions
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Jerad Rutnam*
>>>>>> *Software Engineer - UI*
>>>>>>
>>>>>> WSO2 Inc.
>>>>>> lean | enterprise | middleware
>>>>>> M : +94 77 959 1609 | E : je...@wso2.com | W : www.wso2.com
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Jerad Rutnam*
>>>>> *Software Engineer - UI*
>>>>>
>>>>> WSO2 Inc.
>>>>> lean | enterprise | middleware
>>>>> M : +94 77 959 1609 | E : je...@wso2.com | W : www.wso2.com
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> Dev@wso2.org
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Dimuthu De Lanerolle
>>>> Software Engineer
>>>> WSO2 Inc.
>>>> lean . enterprise . middlewear.
>>>> http://wso2.com/
>>>> Tel. : +94 11 2145345  Fax : +94 11 2145300  email : dimut...@wso2.com
>>>>
>>>>
>>>
>>>
>>> --
>>> *Jerad Rutnam*
>>> *Software Engineer - UI*
>>>
>>> WSO2 Inc.
>>> lean | enterprise | middleware
>>> M : +94 77 959 1609 | E : je...@wso2.com | W : www.wso2.com
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>
>
> --
> *Jerad Rutnam*
> *Software Engineer*
>
> WSO2 Inc.
> lean | enterprise | middleware
> M : +94 77 959 1609 | E : je...@wso2.com | W : www.wso2.com
>



-- 
*Jerad Rutnam*
*Software Engineer*

WSO2 Inc.
lean | enterprise | middleware
M : +94 77 959 1609 | E : je...@wso2.com | W : www.wso2.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to