Python script for SVG to PNG conversion with Extjs -
i'm trying save chart converting svg png python script. start storing svg data in variable :
var svgdata = ext.draw.engine.svgexporter.generate(chart.surface);
when alert(svgdata)
, can see output correct.
but when send server :
ext.draw.engine.imageexporter.defaulturl = "data/svg_to_png.py?svgdata="+svgdata;
the svgdata has been sent looks :
<?xml version=
i'm new extjs, please me on one. right way send svg data python script , render png image ?
this python script :
import cairo import cgi import rsvg print "content-type: image/png\n\n" arguments = cgi.fieldstorage() img = cairo.imagesurface(cairo.format_argb32, 640,480) ctx = cairo.context(img) handler= rsvg.handle(none, str(arguments["svgdata"])) handler.render_cairo(ctx) img.write_to_png("svg.png")
help me please!
<div style="display:none;"> <iframe id="file_download_iframe" src="blank.html"></iframe> </div>
you need blank html page on server work in browsers. blank.html page empty page satisfy ifram has page in it.
then need basic form hidden somewhere too:
<div style="display:none;"> <form id = "file_download_iframe_form" name = "file_download_iframe_form" target = "file_download_iframe" method = "post" action = "data/svg_to_png.py" > <input type="hidden" id="svgdata" name="svgdata"/> </form> </div>
then have javascript function this:
function getimage(svgdata){ var form = document.getelementbyid("file_download_iframe_form"); document.getelementbyid("svgdata").value = svgdata; form.submit(); };
Comments
Post a Comment