Download Raphael canvas in SVG or PDF format

I use Raphael to create dynamic renderings. Is it possible to allow the image created on Canvas to be downloaded as SVG / PDF or another image format?

+6
source share
3 answers

There are no pieces of information here, namely browser support, server / client solution and whether the costs are in order or not. Therefore, I will try to give you an exhaustive answer.

For a client solution, you can use DocRaptor . Just feed the SVG tree to DocRaptor. This works for SVG browsers (all since 2005, with the exception of IE prior to version 9). Please note that DocRaptor has a fee for converting documents to PDF. For a free server-side solution for converting an SVG tree to PDF, I would suggest using wkhtmltopdf as suggested in this answer .

For IE6-8, which RaphaΓ«l creates for VML, you can create a PHP solution using the Vector Converter library. When the conversion from VML to SVG is complete, send the SVG to the DocRaptor (or wkhtmltopdf).

There is no free VML / SVG β†’ PDF client solution that works for VML or SVG. For construction, this would mean interpreting SVG and / or VML, creating a PDF file from it using JavaScript (there are JS PDF library attempts ) and sending it to the client using some Flash technique . I think no one has tried to build it yet. I could.

+9
source

pdfkit seems to be the way using a browser to make the client part of the node code. There is a good demonstration here.

+5
source

You can save as image using canvg and canvas2image .

+1
source

Source: https://habr.com/ru/post/888157/


All Articles