Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Added support for downloading PNG file along with SVG file. #15

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from

Conversation

napsternxg
Copy link

I have added a new file called svg-crowbar-png.js
In the above file I have added a function called downloadPNG() which uses the SVG source to create a PNG file ready for download using the canvas. This change also adds a new button called "Download PNG" and changes the original download button to "Download SVG" and gives user option to choose either downloads.

The changes also include a new link for bookmarklet which adds the link to the svg-crowbar-png.js file served from CDN.rawgit.com

All the changes can be seen at the demo on: http://shubhanshu.com/svg-crowbar/

…(source). This adds a new button for downloading the PNG file called download PNG. Also the last button is renamed as Download SVG
@hugolpz
Copy link
Contributor

hugolpz commented Feb 28, 2015

@napsternxg : it may be relevant to rather embed the raster. See #16

@techtonik
Copy link

Uncaught ReferenceError: d3 is not defined

@techtonik
Copy link

A very useful feature. For example to paste diagrams like this into Github you need to convert it to PNG.

@dfan
Copy link

dfan commented Jul 31, 2016

There's a DOM 5 in Safari when the image source is encoded to base64 (line 247 in napster's pull request) because Safari doesn't like escape characters but Chrome is okay with it.
This will work instead:
Original: 'data:image/svg+xml;base64,'+ btoa(source.source);
New: 'data:image/svg+xml;base64,'+ btoa(unescape(encodeURIComponent(source.source)));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants