Forked and improved from cworth's svg2pdf