Hi Radzen team,
First of all, thank you for providing the QRCode component. It works well and is very easy to use.
I have a small API suggestion that I believe would make it much more flexible.
Current behavior
Currently there are two export methods:
-
ToSvg()returns the SVG content as a string. -
ToPng()converts the SVG to PNG and immediately downloads the image.
This makes ToPng() difficult to use in scenarios where developers need the PNG data instead of downloading it directly, such as:
-
Saving to a database
-
Returning the image from an API
-
Embedding it into a PDF or Word document
-
Processing it further before sending it to the client
-
Uploading it to cloud storage
Suggested changes
Instead of the current behavior, I would suggest separating the two responsibilities:
-
Keep the current download functionality, but rename it to something like:
DownloadPng()
-
Change
ToPng()so that it returns the generated PNG instead of downloading it automatically, for example:-
byte[] -
Stream -
or another suitable image representation.
-
This would make the API more consistent with ToSvg(), which already returns the generated content instead of triggering a download.
Output size / scale
It would also be very useful if both DownloadPng() and ToPng() accepted optional parameters to control the output size, for example:
-
width
-
height
-
scale
This would allow developers to generate higher-resolution QR codes without having to post-process the image themselves.
Example:
var png = qrCode.ToPng(width: 1000, height: 1000);
// or
var png = qrCode.ToPng(scale: 4);
Benefits
-
Better separation of responsibilities.
-
More consistent API design.
-
Supports many server-side and document-generation scenarios.
-
Gives developers control over the output resolution.
-
Existing download functionality can still be preserved through
DownloadPng().
I think these changes would make the QRCode API much more flexible while remaining fully backward compatible if DownloadPng() is introduced alongside the new ToPng() behavior.
Thank you for considering this suggestion!