gofpdf icon indicating copy to clipboard operation
gofpdf copied to clipboard

Cannot parse SVG with <g> tags

Open nicholaspuglia opened this issue 5 years ago • 2 comments

When parsing an svg before writing it to a pdf using SVGBasicParse(), if the svg contains tags then it does not appear on the pdf. My current workaround is to remove the tags from the svg manually however, it would be convenient to remove this extra step.

nicholaspuglia avatar Sep 30 '19 01:09 nicholaspuglia

@nicholaspuglia -- can you provide a small example of an SVG file before and after the tags are removed?

jung-kurt avatar Sep 30 '19 12:09 jung-kurt

Before the tag is removed:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="209" height="8"> <g stroke-linejoin="round" stroke-linecap="round" fill="none" stroke="black"> <path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M 1 1 c 0.23 0.04 8.63 1.76 13 2 c 7.65 0.42 15.11 -0.35 23 0 c 23.02 1.02 43.97 3.11 67 4 c 12.35 0.48 23.88 0.46 36 0 c 5.76 -0.22 11.23 -1.83 17 -2 c 17.18 -0.51 51 0 51 0" /> </g> </svg>

After tag is removed:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="209" height="8"> <path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M 1 1 c 0.23 0.04 8.63 1.76 13 2 c 7.65 0.42 15.11 -0.35 23 0 c 23.02 1.02 43.97 3.11 67 4 c 12.35 0.48 23.88 0.46 36 0 c 5.76 -0.22 11.23 -1.83 17 -2 c 17.18 -0.51 51 0 51 0" /> </svg>

nicholaspuglia avatar Sep 30 '19 22:09 nicholaspuglia