-
Notifications
You must be signed in to change notification settings - Fork 18
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
Can we have a download option, to download the QR code as png image? #37
Labels
enhancement
New feature or request
Comments
Same here! |
same here |
as temporary solution, i used this:
Then, somewhere create and render Canvas Element, storing value as
and somewhere in your component:
So then create some function
or share:
|
Here is a simpler version:Component: <div id="img">
<Image
text={"https://github.com/bunlong/next-qrcode"}
options={{
type: "image/png",
errorCorrectionLevel: "M",
margin: 3,
scale: 4,
width: 200,
color: {
dark: "#fff",
light: "#000B40",
},
}}
/>
<button onClick={downloadImage}>Download</button>
</div> JS function to add download functionality to the button: function downloadImage() {
const image = document.getElementById("image");
const div = document.getElementById("img");
const image = div.querySelector("img");
const a = document.createElement("a");
a.href = image.src;
a.download = "image.png";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a use case where i want to show the QR and i want to allow user to download that QRCode as png image which can be shared. Can we include such functionality?
The text was updated successfully, but these errors were encountered: