Saving SVG: I only want to save the canvas, not lines drawn outside

Duplicate of this thread: https://discourse.processing.org/t/creating-svg-limited-to-canvas-size/38426/9