Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

even afetr using canvg, i am not able to download as png in IE11 #117

Closed
may16197 opened this issue Nov 14, 2016 · 13 comments
Closed

even afetr using canvg, i am not able to download as png in IE11 #117

may16197 opened this issue Nov 14, 2016 · 13 comments

Comments

@may16197
Copy link

Hi,
i am trying to use this on IE10 and i am getting below error "Rendered SVG images cannot be downloaded in this browser.". Which IE version this canvg option works?

I am using canvg as below:
var canvas = document.querySelector("canvas");
var svg = document.querySelector('svg');
saveSvgAsPng(svg, "topo_diagram.png",{canvg:window.canvg(canvas,svg)} );

this works fine in firefox..

any help on this is greatly approciated.

regds,
DD

@exupero
Copy link
Owner

exupero commented Nov 14, 2016

I'll direct the question to @Jephuff as I've not used canvg.

@Jephuff
Copy link
Contributor

Jephuff commented Nov 14, 2016

saveSvgAsPng will call canvg directly, so all you need to pass is a reference to the function. Try this

var svg = document.querySelector('svg');
saveSvgAsPng(svg, "topo_diagram.png",{canvg:window.canvg} );

@exupero exupero closed this as completed Nov 14, 2016
@may16197
Copy link
Author

may16197 commented Nov 16, 2016

Hi Jephuff ,

Thanks for replying. I have tried whatever you have mentioned .Still it doesnt work.IE stops responding

The recent saveSvgAsPng.js doesnt work in any browser.

regds,
DD

@may16197 may16197 changed the title even afetr using canvg, i am not able to download as png in IE10 even afetr using canvg, i am not able to download as png in IE11 Nov 16, 2016
@Jephuff
Copy link
Contributor

Jephuff commented Nov 16, 2016

If you can reproduce in a jsfiddle I can take a look.

@may16197
Copy link
Author

Hi Jephuff,

here my file in jsfiddle..
https://jsfiddle.net/asew/ja9bxz2r/4/

I am not too familiar with jsfiddle. So i am not sure how it will pick external resources. I have mentioned them in external resources.

thanks,
DD

@Jephuff
Copy link
Contributor

Jephuff commented Nov 17, 2016

For the external resources just get the links to the files on a cdn.

d3 provides a link on there home page (looks like your using v3 though, so change v4 to v3 in the url.)
canvg provides the links on their github page (change them to https) and for anything else like, saveSvgAsPng, grab a link to the raw asset on github and change raw.githubusercontent to rawgithub

Once you the svg rendering, send the updated fiddle over :) (I'd recommending testing the link in an incognito window first, just to ensure you don't have any unsaved changes)

@may16197
Copy link
Author

may16197 commented Nov 21, 2016

somehow , in jsfiddle the svg is not loading..let me try it once more.

for me, the recent saveSvgAsPng.js is not wrking at all in anybrowser even if i do not use canvg option. If i switch to old js file, it works for chrome and FF.

does the size of SVG matters? I have around 500+ nodes and links

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
Copy link
Owner

exupero commented Nov 21, 2016

It sounds like you may have a problem with your SVG. Does the developer console log anything when you try to download? It's possible the SVG is invalid.

@may16197
Copy link
Author

may16197 commented Nov 22, 2016

Thanks for the reply and patience.

my function:
function download(){
var svg=document.querySelector("svg")
saveSvgAsPng(svg,"topo.png",{canvg:window.canvg} );
}

wow...atlast i could find out the problem...The problem was my function had download() name and js file too has download function .

Now the file is getting downloaded, but if i use canvg option, i get empty png file...the same issue with all browsers.

but in my application,on IE, it throws "Rendered SVG images cannot be downloaded in this browser"

plz help!!

thanks,
DD

@Jephuff
Copy link
Contributor

Jephuff commented Nov 22, 2016

That error sounds like either window.canvg is undefined or it's an older version of saveSvgAsPng.
Could you confirm that canvg is being loaded properly? (set a breakpoint on this line saveSvgAsPng(svg,"topo.png",{canvg:window.canvg} ); and check the value
And also confirm you have the latest version of saveSvgAsPng (you could always search the source for it for any reference to canvg)

@may16197
Copy link
Author

may16197 commented Nov 25, 2016

Hi,

window.canvg is not 'undefined' and I am using newst version of saveSvgAsPng., when I debug, everything looks fine and no erros as well. But the downloaded file is empty. I could see canvg file being referenced , everythign flows smoothly. Not able to understand the issue.

thanks,
DD

@may16197
Copy link
Author

Hi Jephuff,

when i changed the code in saveSvgAsPng.js at line num 250 to this..

if(options.canvg) {
options.canvg(canvas, src,{
ignoreMouse : true,
ignoreAnimation : true,
renderCallback : function(){ cb( png,canvas ); }
});

the PNG file is loaded with nodes and images. But CSS is not applied.
Any hint would be highly appriciated.

regds,
DD

@Jephuff
Copy link
Contributor

Jephuff commented Dec 16, 2016

I would need a fiddle figure out whats going on with the styles.
Probably I should have added the ignoreMouse: true andignoreAnimation: true options.

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

No branches or pull requests

3 participants