Download QRCode

Community Driven Extensions Project
Post Reply
User avatar
cloudwalker78
Posts: 4
Joined: 07 Oct 2011, 10:53

05 May 2014, 00:34

Hi,

I generated a QR Code with the pe:qrCode tag.

How can I implement a download function for the generated code now?
I would like to download the code by clicking a button.
I can't find a solution for this.

Hope s.o can help me with this.

Thanks.
Primefaces 5.0RC1, Mojarra 2.2.4, JBoss 7.1

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

05 May 2014, 14:37

I hope you can do this functionality.You can get the canvas URL(with the help of toDataURL) from the QR code component.Then you can convert this URL to PNG file in the server side.Once you got the png file then you can apply the fileDownload component to download the image.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

User avatar
cloudwalker78
Posts: 4
Joined: 07 Oct 2011, 10:53

06 May 2014, 12:48

sudheer wrote:I hope you can do this functionality.You can get the canvas URL(with the help of toDataURL) from the QR code component.Then you can convert this URL to PNG file in the server side.Once you got the png file then you can apply the fileDownload component to download the image.
Thanks, that solution worked !
Now I get the canvas URL with javascript toDataURL() as base64 data:image and send that to the server.
Ther server decodes the base64 string and generates the png InputStream and StreamedContent needed for the filedownload component.

Works perfectly. Thanks.
:)
Primefaces 5.0RC1, Mojarra 2.2.4, JBoss 7.1

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

06 May 2014, 20:50

cloudwalker78 wrote:
sudheer wrote:I hope you can do this functionality.You can get the canvas URL(with the help of toDataURL) from the QR code component.Then you can convert this URL to PNG file in the server side.Once you got the png file then you can apply the fileDownload component to download the image.
Thanks, that solution worked !
Now I get the canvas URL with javascript toDataURL() as base64 data:image and send that to the server.
Ther server decodes the base64 string and generates the png InputStream and StreamedContent needed for the filedownload component.

Works perfectly. Thanks.
:)
Glad to hear it works :)
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

andissul
Posts: 4
Joined: 30 Mar 2014, 18:50

14 Jul 2015, 20:12

sudheer wrote:I hope you can do this functionality.You can get the canvas URL(with the help of toDataURL) from the QR code component.Then you can convert this URL to PNG file in the server side.Once you got the png file then you can apply the fileDownload component to download the image.

can anyone post an example of this?

andissul
Posts: 4
Joined: 30 Mar 2014, 18:50

14 Jul 2015, 20:37

Can anyone post an example to get a url of pe:qrCode?

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests