<community>of XML and SVG Developers</community>
This is a discussion on How to copy SVG into clipboard using JavaScript? within the SVG Questions forums, part of the SVG Forums category; Hello everybody. I interest in the folowing... While right-click on the SVG canvas there is pop-up menu option named "Copy ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
I interest in the folowing... While right-click on the SVG canvas there is pop-up menu option named "Copy SVG" which copy SVG into clipboard .Could you pls help me how to copy SVG content into clipboard using JavaScript.I want the the same effect like if have been chosen the mentioned option, but not from that pop-menu...
__________________ rbeit gibt die Freilesung! |
| |||
|
Hello Cadok, Please take a look at this example : http://www.mecxpert.de/svg/domtree.html It is very powerful for grabbing the current SVG DOM tree using Javascript. HTH (hope this helps), |
| |||
|
Hello johnfrost! I've already used this example, but I found some trouble there It works only while saving SVG-tree for the first time... When I try to save again nothing changes on the display, but such coment appears: "junk after line ..." This means that after ending tag </svg> the script writes again <svg> and writes svg-tree again not destroying previous tree. :? So could you pls post me some another workable samles to study and compare. Thank for al :lol: l |
| |||
|
Yeah, it gets tricky, To save your changes - use postURL to send your SVG DOM content to the url of your choice. You can then grab your SVG DOM there. Or if using Adobe SVG Viewer try this : <?AdobeSVGViewer save="snapshot"?> <svg onload="initiate(evt)"> <script type="text/javascript"> <![CDATA[ function initiate(evt) { var circ = document.createElement("circle"); circ.setAttribute("cx",60); circ.setAttribute("r",20); document.rootElement.appendChild(circ); } ]]> </script> </svg> Of course you can also use printNode() and put result in alert to quickly verify what happened. Let me know if you would like a more detailed example of any of these approaches. Best, |
| |||
| Quote:
It preferable to have some alternative meanings of clipping into clipboard 8) Thank you lot...
__________________ rbeit gibt die Freilesung! |
| |||
|
Unfortunately you can't copy directly to the OS clipboard using the standard ASV v3/v6 software. However, I have heard that this may be possible using ASV if you are using IE with a 'trusted' website. Then with ActiveX you could grab the SVG image data with something like this : window.clipboardData.setData('yourText',yourString ). But this restricts you to one specific environment. I've also read in a post by Doug Scheppers that another option would be to install Batik on your web server: http://xml.apache.org/batik/svgrasterizer.html Then you can rasterize your SVG image on the server and in IE you can use script to copy this raster image to the user's clipboard. Those are the only known options at this time. Regards, |
![]() |
| Tags |
| clipboard, copy, javascript, svg |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Inkjet Printer Cartridges
High quality low cost inkjet printer cartridges from Prink. Free UK delivery on compatible inkjet printer cartridges. We stock over 50,000 cartridges
replacement ink cartridges
Get replacement ink cartridges from a trusted specialist supplier. We stock major brands and our own guaranteed compatible cartridges.
Hard disk drive repair recovery manchester
Problem with your hard disk drive? Contact Data Clinic in Manchester for the best repair and data recovery service.