Didn't look at your code but I had good results with using dom-to-pdf with converting quite complex svg's to pdf's cliƫnt site. Though I remember it needed a trivial fix to render pdf's larger than the current viewport.
You might want to take a look.