Generating QR Codes in Lotus Script
Daniel Nashed – 29 October 2024 11:02:12
For a new project I need to generate QR codes.
There are many tools around to generate nice looking QR codes.
But I can't use an external service for security reasons.
In my case I need to send data to register users.
One of the most promising projects is https://www.nayuki.io/page/qr-code-generator-library
It comes with multiple implementations including C, C++, Java and JavaScript.
I took the fast Java implementation and put it into a Java Script Lib and wrote a small Lotus Script Script Lib to consume it.
In a first step I implemented the following three functions:
Function WriteFilePNG (filename As String, payload As String, scale As Integer, boarder As Integer) As Boolean
Write a PNG QR image to disk. This is helpful when you need to attach it somewhere or serve it directly from that location -- like HTML directory.
Function GetBase64PNG (payload As String, scale As Integer, boarder As Integer) As String
Generate a QR code in base64 encoded PNG format returned as a string.
This is useful if you want to use it in passthru HTML with a data source image directly inline from the document.
But it is also useful for sending it around in mail.
Function SendMailWithImage (recipient As String, subject As String, bodyText As String, Base64PNG As String) As String
Sending a mail with an embedded image from memory not attaching it from disk might be a bit tricky.
So I wrote a small helper function to craft a MIME message with a data source image.
Those three functions are all I need for my use cases and I have many other ideas what to use this for.
Sample database
I have created a small database to generate QR codes and send them.
It's a test and demo application (I used Domino Restyle on Nomad Web to beef the UI up by the way).
The database can generate and send QR codes.
If this would be useful I can share the database.
I would be interested to hear how you create QR codes and what your requirements are.
This is not the replacement for nice and fancy QR codes. It's intended for system generated QR codes for technical reasons like a login link, Wifi networks etc.
But I would also interested to hear what other more fancy QR code services you use.
There are a lot of online services with nice looking QR codes.
-- Daniel
- Comments [3]