exupero / saveSvgAsPng

Save SVGs as PNGs from the browser.
MIT License
1.09k stars 362 forks source link

updated saveSvgAsPng.js doesnt work in any browser. #119

Closed may16197 closed 7 years ago

may16197 commented 7 years ago

I have a month old js file which works fine in FF and chrome and now i have downloaded the recent js file and saw that on any browser it doesnt work.

is it only with me? or anybdy else have tested this?

exupero commented 7 years ago

Please be more specific about what "doesn't work" means. Is there an error, or does it fail silently? Is it broken for all SVGs or only a particular one? More details are necessary to provide help.

The test page uses the latest version of the code and seems to be working fine.

may16197 commented 7 years ago

Yes. It fails silently. No error and no download too. and When i switch to old saveSvgAsPng.js, it works perfectly fine.

I was trying to use the new updated saveSvgAsPng.js for canvg support.

Thanks, DD

exupero commented 7 years ago

Are you able to download the test images on the test page (http://exupero.org/saveSvgAsPng/)? The script on that page is the latest version, with support added for canvg, though none of the tests actually use it.

If those images work for you (they did for me), the problem is likely something with your specific case. Does a simpler SVG work? If so, there may be a problem with you particular SVG. Are there any console messages? Usually when there's an error that prevents download, the developer console shows it.

What code are you using when you call saveSvgAsPng? Perhaps you've found an edge case where one of the options causes the script to abort.

may16197 commented 7 years ago

i have only these 2 lines: function download(){ var svg = document.querySelector('svg'); saveSvgAsPng(svg,"diagram.png");

}

when i tried to debug with both old and new js files, I found out that new saveSvgAsPng,js keeps on looping and never comes out and hence no download. I dnt know whether its relevent.

exupero commented 7 years ago

Do you know where the script is looping?

Since simple SVGs work on the test page, try removing some parts of your SVG until the download works. Let me know what parts you had to remove to get it working.

may16197 commented 7 years ago

Hi.. Thanks a lot for your help and patience.

The probelm is:

.my application has a fuction named download() and js file too has download function . prob collision and my application download() function was getting called. The function download() in th JS file is newly introduced as to old JS(it was out$.download). thats why, the old JS was working for me.

now i am able to download files until I am using canvg option. ofr canvg option i am getting empty png file.

Thanks, DD