Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

get Text from QRCode

Community Beginner ,
Sep 20, 2017 Sep 20, 2017

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

TOPICS
Scripting
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Sep 21, 2017 Sep 21, 2017

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

...
Translate
People's Champ ,
Sep 21, 2017 Sep 21, 2017

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" );

}

Capture d’écran 2017-09-21 à 22.32.47.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 25, 2017 Sep 25, 2017

Thanks a lot,

works very good and saved me a lot of time...

Have a nice day!

Daniel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 25, 2017 Sep 25, 2017
LATEST

Glad it helped.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines