Copy link to clipboard
Copied
InDesign allows me to place a QRCode made from simple text in the document. Menu: Object / generate QRCode using Indesign 2017.1
Is there a way to read the content from the generated object? I can find the object on the layer but not the underlying text. When hovering with the mouse on the qrCode, the text is shown.
Was already going through the object tree with ExtendScript-Toolkit, not successful though..
Thanks in advance,
Daniel
Hi,
A possible approach given that you properly reached the text based QR ode:
...//Take care of having a valid reference to the QRCode
//Actually it's a EPS file with some embedded link property
var qRCode = app.selection[0];
//We do export a snippet
var tempFile = File ( Folder.temp+"/qr.idms" );
qRCode.exportFile ( ExportFormat.INDESIGN_SNIPPET , tempFile);
//Snippets are xml files
//And the inner QRCode text is clearly exposed
//So what we need is to load the XML string from file
//and turn it into a regu
Copy link to clipboard
Copied
Hi,
A possible approach given that you properly reached the text based QR ode:
//Take care of having a valid reference to the QRCode
//Actually it's a EPS file with some embedded link property
var qRCode = app.selection[0];
//We do export a snippet
var tempFile = File ( Folder.temp+"/qr.idms" );
qRCode.exportFile ( ExportFormat.INDESIGN_SNIPPET , tempFile);
//Snippets are xml files
//And the inner QRCode text is clearly exposed
//So what we need is to load the XML string from file
//and turn it into a regular javascript object
tempFile.encoding = "UTF-8";
tempFile.open("r");
var xObj = XML ( tempFile.read() );
tempFile.close();
tempFile.remove();
//Once that done, it's easy to go and pick the PlainText attribute which hosts the text content
var txt = xObj..@PlainText;
//Finally
if ( txt.length() ) {
alert( txt[0] );
}
else {
alert("No text found sorry" );
}
Copy link to clipboard
Copied
Thanks a lot,
works very good and saved me a lot of time...
Have a nice day!
Daniel
Copy link to clipboard
Copied
Glad it helped.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now