This project has moved. For the latest updates, please go here.

Need to convert SVG to PNG and during conversion need to delete an element with parameter delete="yes"

Jul 15, 2016 at 1:26 PM
Hi all,

can you please help me with a piece of code for below requirement

Need to convert SVG to PNG and during conversion need to delete a svg element with parameter delete="yes"
Coordinator
Jul 15, 2016 at 2:05 PM
SVG does not have a delete attribute in it's specifications so you would need to do it yourself with something like XElement. And when that is done you can just use Magick.NET to convert the SVG to PNG.
Jul 15, 2016 at 2:17 PM
hi.. sorry if am not clear on my question.

my sample svg structure is

<svg>
<g delete="yes">
here an image will be present
</g>
</svg>

what i was looking for is i have to convert this svg to png, and while conversion, i need to delete that layer which has custom attribute delete="yes" and then convert to png. but i dont want that to be deleted from SVG . i just need that to be removed from o/p png file.

Please let me know if its possible to do
Coordinator
Jul 15, 2016 at 8:28 PM
You will need to load the SVG into memory into a XElement then remove the nodes marked with 'delete' and then write the XElement to a memorystream. You can then feed this to Magick.NET to convert the SVG image to a PNG file.
Jul 18, 2016 at 1:39 PM
thanks.. it worked :)