The incorrect tag leads to style classes beeing not applied in some SVG viewers (or if you use reportlab).
Geometries are filled although fill is set to none.
If you open the svg and replace "def" with "defs", then all works in reportlab and some other svg viewers.
Needed change: ezdxf/addons/drawings/svg.py:220 - rename "def" to "defs"
To Reproduce
ezdxf 1.3.3
reportlab 4.2.2
`import ezdxf
from ezdxf.addons.drawing import RenderContext, svg, Frontend, layout
from reportlab.pdfgen import canvas
from reportlab.graphics import renderPDF
from svglib.svglib import svg2rlg
from ezdxf.addons.drawing import config as ezdxf_config
Describe the bug SvgBackend produces a svg file with a tag named "" which is wrong and should be re-named to "" according to
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs
The incorrect tag leads to style classes beeing not applied in some SVG viewers (or if you use reportlab). Geometries are filled although fill is set to none.
If you open the svg and replace "def" with "defs", then all works in reportlab and some other svg viewers.
Needed change: ezdxf/addons/drawings/svg.py:220 - rename "def" to "defs"
To Reproduce ezdxf 1.3.3 reportlab 4.2.2
`import ezdxf from ezdxf.addons.drawing import RenderContext, svg, Frontend, layout from reportlab.pdfgen import canvas from reportlab.graphics import renderPDF from svglib.svglib import svg2rlg from ezdxf.addons.drawing import config as ezdxf_config
dxf_doc = ezdxf.new("AC1015", setup=True) msp = dxf_doc.modelspace()
boundary = [ [0., 0.], [1., 0.], [1., 1.], [0., 1.], ]
msp.add_lwpolyline(boundary, close=True)
1. create the render context
context = RenderContext(dxf_doc, export_mode=False)
2. create the backend
backend = svg.SVGBackend()
create a new configuration for a white background
cfg = ezdxf_config.Configuration( color_policy=ezdxf_config.ColorPolicy.COLOR, background_policy=ezdxf_config.BackgroundPolicy.WHITE, )
3. create the frontend
frontend = Frontend(context, backend, config=cfg)
4. draw the modelspace
frontend.draw_layout(msp)
5. create an A4 page layout, not required for all backends
page = layout.Page( 100, 100, layout.Units.mm, margins=layout.Margins.all(2), max_width=100, max_height=100, )
svg file
file = "tmp.svg"
with open(file, "w") as f: f.write(backend.get_string(page))
reportlab pdf
drawing=svg2rlg(file) drawing.scale(0.3, 0.3)
c = canvas.Canvas('tmp.pdf') renderPDF.draw(drawing,c, 10, 40) c.showPage() c.save() `
Screenshots erroneous: working: