[SOLVED] Generate QR codes for calendar entry using ExtendScript

An online generated QR code with QR Code Generator is properly recognised as calendar entry with any QR reader. So it can be transferred to the calendar with just a click.

The following ExtendScript uses the absolutely exact data as previously generated. However, when scanning the QR code created by Script in InDesign, it is not recognized as a calendar entry.

var doc = app.activeDocument;

var QRCode = doc.pages[0].textFrames.add ({ 
        geometricBounds : [ 60,20,150,120 ],
        name: "QR Code",  // Assign name to Layer  
        parentStory : { 
            pointSize : 22,
            appliedFont: "Lucida Grande",
        }
    } 
);

QRCode.createPlainTextQRCode("BEGIN:VEVENTSUMMARY:Total Eclipse - Greenland / Island / SpainDTSTART:20260812T165800ZDTEND:20260812T183400ZEND:VEVENT");

What makes me wonder: The ExtendScript uses the absolutely exact string

BEGIN:VEVENTSUMMARY:Total Eclipse - Greenland / Island / SpainDTSTART:20260812T165800ZDTEND:20260812T183400ZEND:VEVENT

for generating the QR code that was created by the online QR code generator. Nevertheless, the QR code generated by InDesign is not recognized as a calendar entry. Is this a bug?

InDesign javascript

Try to add linebreaks:

Spain\nDTSTART

instead of

SpainDTSTART
1 Like

Thanks a lot, Gregor!!! :pray: :pray: :pray:

Both, DTSTART and DTEND musst have a preceeding \n !!!

For this example its:

…Spain\nDTSTART
…800Z\nDTEND

So, the proper line of code should be like this:

QRCode.createPlainTextQRCode("BEGIN:VEVENTSUMMARY:Total Eclipse - Greenland / Island / Spain\nDTSTART:20260812T165800Z\nDTEND:20260812T183400ZEND:VEVENT");

However, there was a last obstacle (keeping it here as reference). When scanning the QR Code from the Online QR Generator it takes over the event description (in this case Total Eclipse - Greenland / Island / Spain). But with InDesign it does not (the event description must be manually reentered after scanning the QR Code generated by InDesign).

For anybody who might face the same issue, here is the proper syntax/solution:

BEGIN:VEVENT
SUMMARY:Total Eclipse - Greenland / Island / Spain
DTSTART:20260812T165800Z
DTEND:20260812T183400Z
END:VEVENT

Source: Barcode Contents @ GitHub
Or the dry and hard way reading the RFC2445 :grimacing:

So, the final working code is like this:

QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Total Eclipse - Greenland / Island / Spain\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT");

Addendum
It is also possible to add the LOCATION and DESCRIPTION to the QR Code as follows:

BEGIN:VEVENT
SUMMARY:Total Eclipse - Greenland / Island / Spain
LOCATION:Greenland;Island;Spain
DESCRIPTION:Place to be
DTSTART:20260812T165800Z
DTEND:20260812T183400Z
END:VEVENT
QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Total Eclipse - Greenland / Island / Spain\nLOCATION:Greenland;Island;Spain\nDESCRIPTION:Place to be\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT");
1 Like