1 Reply Latest reply on Feb 22, 2017 2:26 AM by Loic.Aigon

    Is there a way InDesign puts the filename in my QR code?




      I am a technical writer (in the Netherlands) and on the back of every document that I make I have to put a QR code.

      This QR code always contains the same information, namely the filename of the document.

      I always use the Plain text option and then I type the filename in the text box, but of course sometimes I forget to update the QR code when the documents revision changes. In that case the filename changes too.


      Is there a way InDesign puts the filename in my QR code, so I don't have to type it manually?

      Must say I'm not really familiar with scripting.


      Many thanks in advance


        • 1. Re: Is there a way InDesign puts the filename in my QR code?
          Loic.Aigon Adobe Community Professional



          It should. However my attempt makes InDesign to crash. The addQR fonction works just fine outside the listener but crashes indesign in the listener.


          It's likely that the document instance is not totally available at the time but I can't see a way to delay. Maybe my fellows will have a clue.


          #targetengine 'onAfterOpen';
          var main = function() {
            var evName = "onAfterOpen",
            ev = app.eventListeners.itemByName ( evName );
            if ( !ev.isValid ) {
            app.eventListeners.add ( 'afterOpen', onAfterOpenHandler ).name = evName;
          function onAfterOpenHandler(evt) {
            var doc = evt.parent;
            if ( doc.constructor.name!='Document' ) return;
            addQR ( doc );
          function addQR ( doc ) {
            var layerName = "__QR__",
            layer = doc.layers.itemByName ( layerName ),
            layer.isValid && layer.remove();
            layer= doc.layers.add({name:layerName});
            layer.move ( LocationOptions.AT_BEGINNING);
            var rect = doc.pages[-1].rectangles.add({geometricBounds:[10,10,25,25], itemLayer:layer});
            //CRASH right after
            rect.createPlainTextQRCode ( String(doc.name) );
          var u;
          //app.doScript ( "main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );


          Let me know if you are facing the same crashes.