PS. I asked the same question here:
http://stackoverflow.com/questions/4118134/saving-raphaeljs-image-as-png-on-internet-explorer
--
Regards,
Michał Nowotka
--
Regards
Michał Nowotka
The raphael.serialize plugin takes this approach:
https://github.com/jspies/raphael.serialize
It iterates over all the objects, extracts the interesting attributes,
and builds a JSON object. The use-case is to send that JSON to a
server which can then reconstruct the SVG, convert it to a raster
format and serve the resulting image file. But, if you have a way to
do this all client-side from an SVG string, that ought to work.
Anyway, I've been using raphael.serialize for this purpose. It's not
complete, there are some node-type cases missing, but the approach
isn't hard. (If you look at the raphael.serialize code, it's very
straightforward and short.) In my fork of raphael.serialize
(https://github.com/ejucovy/raphael.serialize/) I added a few more
cases and also added some special cases to ignore objects with
display:none, etc.
-Ethan
It's simpler because I have proof of concept making a SVG string from
raphael done by iterating over elements stored in "paper" just like it
is done in raphael.serialize plugin. IE just does not support SVG.
That is the reason it outputs VML on IE. If the implementation of SVG
for IE was so easy as you think then I suppose author of raphaeljs
would implement it and we would have one consistent SVG format as an
output for every browser. But if you implemented it I would be happy
to see your proof of concept.
>Maybe nice for your particular use case but a pointless waste of time
>and memory for normal operation.
I don't think this is waste of memory as SVG is human readable format
that can be saved, exported, converted to other vector or raster image
files so if raphael don't use SVG on IE (which is understandable as IE
don't support SVG) at least it could give a SVG string as one of it's
native methods.
My question was if synthesizing SVG string from "paper" object is the
simplest method or it could be achieved in a simpler way as I don't
want to reinvent the wheel. I don't want to argue with anybody. I
asked for help not for review of my idea.
--
Regards
Michał Nowotka
The alternative, which I discussed with Dmitry on IRC yesterday,
is to abstract away the DOM-creation routines in the SVG layer
under an API, so you have methods "createNode", "setAttr" and
maybe another one or two, then you can create an alternate
implementation of that API which directly creates SVG text.
However... do you have to code additional JS to generate the
SVG text? In many cases, it would be desirable to create the
SVG from an existing VML drawing... and then the path taken
by raphael.serialise is much more sensible. Maybe Raphael's
SVG code could be exposed for more re-use, but I now think
the Ed's approach (which I favoured too) is not the right one.
Clifford Heath.
How to do this? I havn't found any js library converting VML to SVG.
Is there some simple mapping between this formats? i don't think so...
I mean from the Raphael objects that were used to create a VML drawing.
Yes, it's possible by bringing the existing SVG mapper into play on
those
Raphael objects (and modifying it to it produces SVG text, not SVG DOM),
but as I said, probably not the best idea.
Clifford Heath.
Did this work by producing SVG DOM nodes (createElement, etc), or
did you have it to produce SVG text directly?
If the latter, can you share your hacked version?
Clifford Heath.
I have very different requrement - all plotting must be done on the client side.
> --
> You received this message because you are subscribed to the Google Groups "Raphaël" group.
> To post to this group, send an email to raph...@googlegroups.com.
> To unsubscribe from this group, send email to raphaeljs+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/raphaeljs?hl=en-GB.
>
>
--
Pozdrawiam
Michał Nowotka