Right now, I am generating a SVG XML string for a QR code that I am able to set as the src attribute of a vector image to display it on the page. I’d like to add a download option so that it can be downloaded as an image file, but I am unsure how to go about this. Is this possible with Wix?
I’ve tried using the FileSaver module, but no luck.
let qrXML;
//sets vector image
generateQRcode(codeToEncode)
.then(qr => {
$w("#vectorImage16").src = qr;
qrXML = qr;
});
//download button
$w('#button23').onClick( () => {
FileSaver.saveAs(qrXML, "qr.svg");
});
Hi Hunter,
Yes, this is nearly impossible to achieve in Wix. However, there are experts like
@code-queen that can do the impossible. You could try her auto download tutorial:
https://www.youtube.com/watch?v=33HT0TY1r9E&feature=emb_title
It the example, she is using dynamic pages but, you can change it a bit if you are using a regular page.
~Hope this helps!~
Arthur
Hi Hunter!
I found a solution using @code-queen 's example I suggested! I tried to create a download button using the example & combining the on_Click event!
It actually works!
Are you using a dynamic page???Here is the code:
import wixLocation from 'wix-location';
import wixCRM from 'wix-crm';
import wixData from 'wix-data';
export function button71_click(event) {
$w("#dynamicDataset").onReady(function () {
let item = $w("#dynamicDataset").getCurrentItem();
let picture = item.image;
let url = picture.split("/")[3];
let filename = item.name;
wixLocation.to(`https://static.wixstatic.com/media/${url}?dn=${filename}`
);
});
}
If you are gust using a normal page, add the on_click event to:
wixLocation.to(`https:{image-url}`)
I hope this clears this problem & I am very excited that I created a download button! I was trying to do this for weeks.
And here I am learning will I am helping!
Thanks for your tutorials @Code Queen Nayeli!
Arthur😁
Thanks for the insight Arthur!
Your solution works for actual images on my site, but I couldn’t get it to work for the qr code since it is a string under the hood and not an actual file. I did however, come up with a work-around by having the button direct users to a different page that has only the qr code and a title, allowing them to do a print or print to PDF to capture it (not quite what I was going for, but it works for now).
Thanks for all the help!
Hi Hunter,
I am trying to do the same thing. I have created the QR code but can’t download it or email it. How are you printing the QR code? Is it via ctrl-p or some other way? I need my users to either be able to print it or save it, but this needs to work on both PC and mobile (so cannot use ctrl-p for mobile).
Appreciate any help
Thanks
Steve
I’m trying to do the same.
Did any one figure it out?