Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

alt

Daniel Nashed

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



Image:Generating QR Codes in Lotus Script


Comments

1Christian Henseler  29.10.2024 20:16:18  Generating QR Codes in Lotus Script

Hi Daniel,

From my point of view it would be marvelous if you would share your db!

Great work & many thanks!

Best regards

Christian

2Ivan  04.11.2024 13:54:20  Generating QR Codes in Lotus Script

Hi Daniel, can you pls share your database?

3Tyron Barrett  05.11.2024 14:51:31  Generating QR Codes in Lotus Script

Consuming Java in LotusScript is my standard dev practice. Allows me to use all kinds of modern libraries without leaving the comfort of LS.

Doing lots of work with JWT, OAuth2, WebAuthn etc. right now, all using JARs and LS agents in a pure Domino environment. No additional installables which is great from an admin & maintenance point of view.

Links

    Archives


    • [HCL Domino]
    • [Domino on Linux]
    • [Nash!Com]
    • [Daniel Nashed]