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

ViewBox value is wrong in svg image #648

Closed
mnmaltsev opened this issue Sep 5, 2022 · 6 comments · Fixed by #650
Closed

ViewBox value is wrong in svg image #648

mnmaltsev opened this issue Sep 5, 2022 · 6 comments · Fixed by #650

Comments

@mnmaltsev
Copy link

From 4.0.0 version when use toDataURL("image/svg+xml") function resulting svg viewBox value has wrong height and width. The problem is
viewBox="${minX} ${minY} ${this.canvas.width} ${this.canvas.height}"
Width should be this.canvas.width / ratio and height should be this.canvas.height / ratio as in previous version.

Bug can be reproduced by demo
image
image

@UziTech
Copy link
Collaborator

UziTech commented Sep 5, 2022

This would cause the issue in #411 wouldn't it?

@mnmaltsev
Copy link
Author

I can not imagine the case when somebody need not drawable space. As you see in your demo it adds empty spaces on bottom and right. I use the same code to handling high DPI

function resizeCanvas() {
    const ratio =  Math.max(window.devicePixelRatio || 1, 1);
    canvas.width = canvas.offsetWidth * ratio;
    canvas.height = canvas.offsetHeight * ratio;
    canvas.getContext("2d").scale(ratio, ratio);
    signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}

as result drawable area scaled and I want to use result svg image as it was in creation step to display it for the user without additional operations with svg.
Is it possible to add option to cut ViewBox size to initial drawable area as in previous version?
This option will satisfy desires of everybody)

@UziTech
Copy link
Collaborator

UziTech commented Sep 7, 2022

I am having a hard time reproducing the issue in #411. I'm thinking this was fixed before that was merged. I think it would be ok to change it back. If you want to create a PR that would be very helpful 😁👍

@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dnlrbz
Copy link

dnlrbz commented Nov 14, 2022

@UziTech the issue is still happening in version. "signature_pad": "^4.1.4", the viewBox, width and height of an SVG is wrong, because of window.devicePixelRatio, which leads to cutting of part of SVG. Could you please add ratio parameter to the toSVG() method?

@UziTech
Copy link
Collaborator

UziTech commented Nov 14, 2022

@dnlrbz the best way to get this fixed would be to create a new issue and provide some code or a repo that can reproduce it along with a video.

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

Successfully merging a pull request may close this issue.

3 participants