Good news, this is now in the next release! There's a new QRCode module that renders codes entirely on your machine, so no online service is needed: https://feedback.objo.dev/feature/1581
For your labels, the workflow is exactly what you describe. Pull the text (or a URL that opens the record) from your database, encode it, and save or print the result:
# The URL could come straight from a field in your database.
Var recordUrl As String = "https://gallery.example.org/paintings/" + recordId.ToString()
Var code As Picture = QRCode.ToPicture(recordUrl, 12) # 12 pixels per module prints well
code.Save("painting-label.png")
A few details worth knowing:
- The generated picture is a black-on-white QR code with the standard quiet zone, using error correction level M (15% recoverable). The same text and scale always produce exactly the same image.
Save() picks the format from the extension. PNG is recommended because it is lossless and keeps the modules crisp, but if you specifically want a JPEG, code.Save("label.jpg") works too.
- For printed labels, pass a larger
pixelsPerModule (the second argument; the default is 10). The exported image is bigger, which scans more reliably at small print sizes. Short codes such as record numbers are fine at modest sizes; longer URLs need a bit more room.
- Empty or oversized text raises a catchable
InvalidArgumentException, so you can show a friendly message instead of crashing.
- There is also
QRCode.ToMemoryBlock(text) when you want the raw PNG bytes, for example to store in a database blob.
To print, draw the picture onto the page in a PrintJob.RenderPage handler with context.DrawPicture(code, x, y).
I've also added a bundled QR Code Generator example: https://feedback.objo.dev/feature/1598 - you'll find it in the Desktop UI category of the Examples window. It covers typing a URL, generating the code, viewing it, and exporting it to disk as a PNG.
Both features will ship in the next Studio release.