Search code examples
exporttelerikqr-codebarcodemaui

How do you export Telerik .Net Maui Barcode as an image?


Anyone have any experience doing this? I generate a QR code fine but I'd like to allow the user to use it outside the app. I've found a few examples of how to do it in the Xamarin version such as:

https://docs.telerik.com/devtools/xamarin/knowledge-base/barcode-image-export

but it depends on a package that is not compatible with Maui/.net7 and I haven't seen a comparable package to replace it with, or a ported example. There isn't a nice 'ToJpeg()' method for it unfortunately.


Solution

  • So based on GeraldVersluis videos:

    var image = await qrCode.CaptureAsync();
    using (MemoryStream ms = new MemoryStream())
    {
        await image.CopyToAsync(ms);
    
        // write the bytes out somewhere
        ...
    }