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

not able to capture svg image #1578

Open
Manaskumar119 opened this issue Jun 28, 2018 · 7 comments
Open

not able to capture svg image #1578

Manaskumar119 opened this issue Jun 28, 2018 · 7 comments

Comments

@Manaskumar119
Copy link

not able to capture svg image ..

Any Solution ,Please help

@Cellcote
Copy link

Cellcote commented Jul 6, 2018

+1, also running into this issue.

@alansouzati
Copy link

+1 here is a codesandbox that reproduces the issue:

https://codesandbox.io/s/wo3oww275k

@motodimago
Copy link

motodimago commented Jul 11, 2018

I can not capture this.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">...</svg>

But I can capture this svg.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48">...</svg>

I just add width and height.

@muratcatal
Copy link

muratcatal commented Aug 14, 2018

I want to add another solution based on @motodimago 's solution, that is for dynamic created svg's which you can not add width or height staticly. I faced that problem with amcharts, which i can not add width and height to created svg charts.

	   
html2canvas(this.ImageCanvas,
		{
            onclone: (element) => {
                const svgElements: any[] = element.body.getElementsByClassName("printable-area")[0].getElementsByTagName("svg");
                Array.from(svgElements).forEach((svgElement) => {
                    const bBox: any = svgElement.getBBox();
                    svgElement.setAttribute("width", bBox.width);
                    svgElement.setAttribute("height", bBox.height);
                });
            },
        }).then((canvas) => {
            document.body.appendChild(canvas);
        });

@Cellcote
Copy link

Thanks @muratcatal , this fixes most of our issues.

@jacknkandy
Copy link

Thanks @muratcatal

Haroenv added a commit to Haroenv/personality-quiz that referenced this issue Aug 24, 2020
@Haroenv
Copy link

Haroenv commented Aug 24, 2020

Just adding here for SEO, this only happened on Chrome for me, not on Safari

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

7 participants