Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE 11 "path" not found error with the v0.5.0-beta4 #1213

Closed
kevin074 opened this issue Sep 7, 2017 · 3 comments
Closed

IE 11 "path" not found error with the v0.5.0-beta4 #1213

kevin074 opened this issue Sep 7, 2017 · 3 comments

Comments

@kevin074
Copy link

kevin074 commented Sep 7, 2017

Hi we've implemented html2canvas and image can be downloaded on chrome fine (with some tweeks still needed), but the same code on IE11/Edge shows the error:
"path" argument is required

could you explain more in detail what does this error mean exactly and if there are typical mistakes that would cause this error.

we are also using bluebird as our promise library. Added in window.Promise = bluebird in our code.

here is how we are currently calling html2canvas

var elem = $([SELECTOR])[0];
var height, width = from elem.height (width)

html2canvas(elem, {
height: height,
width: width,
scale: 2,
logging: true,
onclone: [CUSTOM FUNCTION HERE]
}).then(function (canvas) { ... })

@niklasvh
Copy link
Owner

niklasvh commented Sep 8, 2017

Please share an example on jsfiddle

@kevin074
Copy link
Author

kevin074 commented Sep 12, 2017

Hi sorry for the late reply. I've been spending days to recreate it on the fiddle. In the process I figured out what was wrong with mine. So feel free to look at what I did and close the ticket or add more explanation as you will.

Here are what I found:
PLEASE note that my lead decided to use this particular commit version of library
149244d
so anything I've found pertains to this commit history. Some thing may have changed.

1.) IE11 does not pass the is browser native svg logic in the library, this.support.svg is false.
2.) IE11 gets into the .hasFabric prototype as result of 1.)
3.) .hasFabric checks for window.html2canvas and window.html2canvas.svg
4.) only window.html2canvas is required for it to work, not window.html2canvas.svg also.
(jsFiddle automatically adds window.html2canvas that's why it worked on the fiddle)
5.) Adding window.html2canvas.svg should produce the error of this ticket (unconfirmed, but it's the logical conclusion from my search).
6.) once the canvas object comes back, you can use canvas.msToBlob() to create the blob object and then save it via navigator.msSaveBlob(blob, filename)

https://jsfiddle.net/kevin074/fd0zszhb/15/
you can open the console once you clicked the download button in the JsFiddle. I've added console logs into the library while searching. The fiddle does not contain 5.) or 6.) of my findings above.
A successful IE download will be seeing the canvas object coming back.

Now my downloaded image is not accurate to my app. I have yet to begin to debug the problem, but if you see anything that seems fishy from what I wrote, PLEASE let me know.

@kevin074
Copy link
Author

kevin074 commented Sep 21, 2017

Forgot to comment. I've found the solution.

I used canvg to change SVG -> canvas, and then use html2canvas to generate the rest of the picture. Here is the code i used to integrate the svg

 $svgElements.each(function () {
        var canvas, xml;
        canvas = document.createElement("canvas");
        canvas.className = "screenShotTempCanvas";
        xml = (new XMLSerializer()).serializeToString(this);

        // Removing the name space as IE throws an error
        xml = xml.replace(/xmlns=\"http:\/\/www\.w3\.org\/2000\/svg\"/, '');
        window.canvg(canvas, xml);
        $(canvas).insertAfter(this);
 })

You'd need to re-show the original svg and remove the canvas element after you are done with it.

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

No branches or pull requests

2 participants