Thanks for publishing this library, it's very helpful for including matplotlib plots in PDF reports.
I've run into trouble when my SVG needs to be clipped to its bounding rectangle. I'd like to just clip it, but it also draws the the bounding rectangle.
Here's a small example of what I'm trying to do. The circle is drawn half outside the top boundary of the SVG, so I want to see a semicircle.
Here's what I want the PDF to look like, without drawing the bounding rectangle:
Analysis
I did some investigation, and the problem appears to be that Canvas.clipPath() is receiving stroke=1. That tells it to stroke the clip path. It's hard for me to tell exactly how that stroke value is decided, but it seems to be left as the default when calling convertRect() on the rectangle in the clipping path. Perhaps it should copy the stroke from the rectangle instead of using the default. As you can see in my snippet, I set the stroke, but it was ignored.
Workaround
It's ugly, but I worked around this by monkeypatching Canvas.clipPath(). That just changes it from always drawing the clip path to never drawing it. Some users might want to choose the stroke for each clip path.
Here's my example with the monkeypatch. It produces the second PDF, above.
Thanks for publishing this library, it's very helpful for including matplotlib plots in PDF reports.
I've run into trouble when my SVG needs to be clipped to its bounding rectangle. I'd like to just clip it, but it also draws the the bounding rectangle.
Here's a small example of what I'm trying to do. The circle is drawn half outside the top boundary of the SVG, so I want to see a semicircle.
The PDF looks like this:
Here's what I want the PDF to look like, without drawing the bounding rectangle:
Analysis
I did some investigation, and the problem appears to be that
Canvas.clipPath()
is receivingstroke=1
. That tells it to stroke the clip path. It's hard for me to tell exactly how that stroke value is decided, but it seems to be left as the default when callingconvertRect()
on the rectangle in the clipping path. Perhaps it should copy the stroke from the rectangle instead of using the default. As you can see in my snippet, I set the stroke, but it was ignored.Workaround
It's ugly, but I worked around this by monkeypatching
Canvas.clipPath()
. That just changes it from always drawing the clip path to never drawing it. Some users might want to choose the stroke for each clip path.Here's my example with the monkeypatch. It produces the second PDF, above.
I'm using these versions: