parallax / jsPDF

Client-side JavaScript PDF generation for everyone.
https://parall.ax/products/jspdf
MIT License
29.2k stars 4.67k forks source link

Adding SVG element to PDF #943

Closed davejack1 closed 6 years ago

davejack1 commented 7 years ago

How can I add an SVG element to PDF that I dynamically created and assigned to a variable with javascript?

aorzh commented 7 years ago

Any luck on this?

suuuunto commented 7 years ago

doc.addSVG?

aorzh commented 7 years ago

Yeah, you right. But with hightcharts it was terrible. Funally I resolved it without jsPDF - just 30 strings in js with hightcharts library.

suuuunto commented 7 years ago

Actually I am working on the same issue :) I am using angular2-highcharts but imo highcharts svg are to complex for the doc.addSVG function so that does not work. How did you solve it?

aorzh commented 7 years ago

@suuuunto , I created gist with comments: https://gist.github.com/aorzh/2df77ce9f43198387a87abe84de94dcd Enjoy :)

suuuunto commented 7 years ago

In my case, I try to get a png data uri to add this in a second step to the pdf.

I think I can not do this with your approach, right?

aorzh commented 7 years ago

@suuuunto , how about some png to svg convertion? I foung this: https://github.com/ehtd/png2svg but didn't reviewed yet. Fill free to check. Maybe better swithch our discussion to https://gist.github.com/aorzh/2df77ce9f43198387a87abe84de94dcd ? Because I think this is not in jsPDF scope :-)

Uzlopak commented 6 years ago

We will have in 1.4.1 addSvgAsImage-method added

caneta commented 5 years ago

It should be nice to have a minimal working example...