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

paperjs and canvg svg export in IE #1098

Closed
v1r opened this issue Jul 6, 2016 · 3 comments
Closed

paperjs and canvg svg export in IE #1098

v1r opened this issue Jul 6, 2016 · 3 comments

Comments

@v1r
Copy link

v1r commented Jul 6, 2016

I have some problems with the exported svg when it is serialized with canvg library in IE.

I had to hack the library in order to support that by editing the following:

    Project.inject({
            exportSVG: function(options) {
                options = setOptions(options);
                var layers = this.layers,
                    view = this.getView(),
                    size = view.getViewSize(),
                    node = createElement('svg', {
                        x: 0,
                        y: 0,
                        // To get more consistent scaling across browsers always ensure you specify a viewBox
                     --> //  viewBox: "0,0," + size.width + "," + size.height,
                        width: options.width || size.width,
                        height: options.height || size.height,
                        version: '1.1',
                        // Removed this as it's causing a serializing bug when the svg is passed to canvg library
                  -->    //'xmlns:xlink': 'http://www.w3.org/1999/xlink'

Can you please fix this in the future release?

@lehni
Copy link
Member

lehni commented Jul 7, 2016

This sounds like an incompatibility in canvg, not paper.js, and should be addressed there, not here. Both of these values are required to address existing issues in browsers. Removing them will break things. Also please note that we're not stating anywhere that canvg is supported.

@lehni
Copy link
Member

lehni commented Jul 7, 2016

This may be related: canvg/canvg#189

@lehni
Copy link
Member

lehni commented Jul 7, 2016

But the real question is: Why do you use canvg to export SVG as a bitmap? Paper.js is already natively drawing into a canvas, and the content of the canvas can be exported: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL

You can also use Item#rasterize() to turn any part of the scene-graph into a Raster item, and from this you can call Raster#toDataURL() to get its file content as a data URL. It supports the same arguments as the native HTMLCanvasElement#toDataURL().

You seem to be attempting to do the same in a very roundabout way.

@lehni lehni closed this as completed Jul 8, 2016
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