I am trying to grasp the InDesign ExtendScript API-Documentation but do not understand how to pass properties to the method.
The method createPlainTextQRCode accepts three parameters according to the documentation:
plainText: *String*
qrCodeSwatch: *Varies Swatch String*
withProperties: *Array of String*
The description for withProperties
states:
Initial values for properties of the new Button. Above parameters can also be passed as properties (Optional).
If I pass two parameters (plainText
and qrCodeSwatch
) like the following example code it works:
QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0");
When trying to add some properties (from Property Listing) to the method call like this, the properties {visible: false, locked: true, name: "Foo"}
are ignored:
QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0", {visible: false, locked: true, name: "Foo"});
The following attempt to pass the properties as an array throws an exception:
QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0", [visible: false, locked: true, name: "Foo"]);
Passing plain key/value-pairs throws an exception too:
QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0", visible: false, locked: true, name: "FOO");
Am I just using the wrong syntax or have I misinterpreted the documentation in some way?
##################################################################
In case you wanna play around, here is the plain simple code snippet:
var doc = app.activeDocument;
var QRCode = doc.pages[0].textFrames.add ({
geometricBounds : [ 60,20,150,120 ]
}
);
QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0");
// QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0", {visible: false, locked: true, name: "Foo"});
// QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0", [visible: false, locked: true, name: "Foo"]);
// QRCode.createPlainTextQRCode("BEGIN:VEVENT\nSUMMARY:Foo\nLOCATION:Nowhere\n\nDTSTART:20260812T165800Z\nDTEND:20260812T183400Z\nEND:VEVENT", "C=100 M=90 Y=10 K=0", visible: false, locked: true, name: "Foo");
##################################################################
Allthough, properties can be assigned to the textFRames-Object like this:
var QRCode = doc.pages[0].textFrames.add ({
geometricBounds : [ 60,20,150,120 ],
name: "QR Code",
locked: true,
visible: true
}
);
it is not what I am looking for. I would really like to understand the withProperties
part of the createPlainTextQRCode
method.