22 Replies Latest reply on Apr 21, 2013 10:28 PM by Trevorׅ

    [JS CS6] Is anybody able to get button’s printableInPdf property?

    Kasyan Servetsky Level 5

      Hi All,

       

      Is anybody able to get button’s printableInPdf property?

       

      I always get the following error whenever I’m trying to access it (Grrr! ):

      The content of this object has multiple values for this graphic attribute.

       

      Despite the fact it is present in the scripting reference

      4.jpg

      it never appears in Data Browser

      3.jpg

       

      Is that a bug or what?

       

      Regards,

      Kasyan

        • 1. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
          drerol74 Level 2

          Hallo Kasyan,

           

          i got the same error message (in German, CS6). But if i set it true or false then it works. Weird ...

           

          printableInPdf.png

          browser.png

           

          Roland

          1 person found this helpful
          • 2. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
            Trevorׅ Adobe Community Professional

            Hi Kasyan,

             

            A bit weird but if you set the value myButton.printableInPdf = 1 or 0 then you can see it. You can use a try catch to se if it was set and then if neaded set it.

            _ Source5_2013-04-14_00-39-52.png

            To me it looks a bit buggy but I'm not close to 100% sure

             

            Trevor

            1 person found this helpful
            • 3. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
              Trevorׅ Adobe Community Professional

              Silly me,

               

              I didn't see Rolands answer above!

              • 4. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                Kasyan Servetsky Level 5

                Thank you both, Roland and Trevor.

                But the problem is that I don't want to change it. I started writing this script and simply want to get its value.

                • 5. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                  drerol74 Level 2

                  It's a bit like Schrödinger's cat, maybe Adobe's Cat. Only when you change the value, you know the value ;-)

                   

                  Maybe that could work (as Trevor pointed out):

                   

                  var _button = app.selection[0];

                  try {

                    _printable = _button.printableInPdf;

                  } catch (e) {

                    _printable = true;

                  }

                   

                  $.writeln(_printable);

                   

                  I think it is a bug in the UI.

                   

                    Roland

                  • 6. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                    Trevorׅ Adobe Community Professional

                    Yes Roland that was exactly the type of thing I had in mind and stated to post the same sort of code but...

                    There's a bit of a problem. See the screenshot below

                    _2013-04-14_17-28-18.png

                    If the Normal state is selectected then all's fine (I think) and the result seems to be correct but if one of the other states is selected then in CAN (BUT NOT ALWAYS) show true when it is false.

                     

                    Here's a link to the document with the problematic button

                    The other buttons in the file seem to work as expected.

                     

                    If one can access the normal state of the button (doesn't sound too tough) then I think we might have a solution.

                     

                    Trevor

                    • 7. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                      Trevorׅ Adobe Community Professional

                      Ok this look like it works (based on Rolands)

                       

                      var _button = app.selection[0],
                              bs = _button.states.everyItem().getElements();
                      if (!bs[0].active)
                      {
                      for (var l = 1; l<bs.length; l++) if (bs[l].active) activeState = l;
                      _button.states[0].active =1;
                      _button = app.selection[0].parent;
                      checkPrintable();
                      _button.states[activeState].active = true;
                      _button.select()
                      }
                      else checkPrintable();
                      
                      
                      function checkPrintable()
                      {
                          try {
                            _printable = _button.printableInPdf;
                          } catch (e) { 
                            _printable = true;
                          }
                      }
                      alert ("Printable: " + _printable);
                      

                       

                      _2013-04-14_18-41-15.png

                      • 8. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                        Kasyan Servetsky Level 5

                        Thank you, Trevor. I did as you suggested.

                         

                        Why did you use this line:

                        _button = app.selection[0].parent;
                        

                        I think it's unnecessary and removed -- the script works the same way.

                         

                        Kas

                        • 9. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                          Trevorׅ Adobe Community Professional

                          Hi Kasyan,

                           

                          Glad it help.

                           

                          I put that line for a good reason but you took it out for a better one!

                           

                          I put it in before the script was finished when it didn't have the line   _button.select() in it.

                           

                          Do the following to catch the bug.

                          1) Select a button and make it's active state not the normal one

                          2) Escape both lines i.e. the line _button.select() and the line _button = app.selection[0].parent

                          3) Run the program twice in a row

                           

                          You will see that the script will throw an error because it changes its selection from the button to the button state and you can't check the printableInPdf of the state so the script would throw an error on it's second run.

                           

                          When the button is reselected with _button.select() you won't get the error and that's why you didn't see the point of it.

                           

                          In short as the script is the line is not needed and is there because I forgot to take it out.  This sort of thing can happen quite easily on freebie scripts .

                           

                          Obviously in your script you are going to loop though the buttons without selecting them in which case the line has no place.

                           

                          Regards

                           

                          Trevor,

                           

                          P.s. please mark the question as answered

                          • 10. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                            Trevorׅ Adobe Community Professional

                            Hey Kasyan!

                             

                            We should have used activeStateIndex and not loop though the states using active.

                             

                            var _button = app.activeDocument.buttons.everyItem().getElements(),
                                  l = _button.length, as,  _printable;
                            
                            while (l--) 
                            {
                                if ((as = _button[l].activeStateIndex) != 0) 
                                    {
                                        _button[l].activeStateIndex = 0;
                                        checkPrintable(_button[l]);
                                        _button[l].activeStateIndex = as;
                                     }
                                else checkPrintable(_button[l]);
                            } 
                            
                            function checkPrintable(myBut)
                            {
                                try {
                                  _printable = myBut.printableInPdf;
                                } catch (e) { 
                                  _printable = true;
                                }
                            $.writeln ("Button " + myBut.index + " Printable: " + _printable);
                            }
                            
                            • 11. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                              Laubender Adobe Community Professional & MVP

                              Hi together!


                              I like to comment the script Kasyan is linking to: "Export button description settings".

                              After seeing into the code, I wonder if the script is really able to catch all buttons in a document.

                               

                              I don't think so.

                               

                              A line like this:

                               

                              var someButLikelyNotAllButtons = app.activeDocument.buttons.everyItem().getElements();
                              

                               

                              does not get to buttons that are nested.

                               

                              With nested I mean:
                              Buttons inside groups, buttons inserted in other objects like rectangles MSOs (MultiStateObjects), button anchored to text frames.
                              I think you get the picture…

                               

                              For people using buttons extensively like the users of the ADPS or other Digital Publishing solutions for InDesign a script that lists all (or some) properties of all buttons in a document could be of immense help.

                               

                              Ok. then what next?
                              Doing the grand tour through all page items and single out the button objects with the old "allPageItems" routine?

                               

                              Sure, with that we could catch all buttons in groups, anchored objects, and pasted inside other geometric obejcts like rectangles, ovals and polygons.

                               

                              But unfortunately, there is another beast that must be tamed in this regard:
                              MSOs (MultiStateObjects).

                               

                              And here we have a real nasty challenge:

                               

                              "myDocument.allPageItems()" gets only all page items that are seen in the UI, if you open the Layers panel and expand all tiny triangles to show the structure of the spread. Of course "myDocument.allPageItems()" does more than that. It get's those on MasterPages as well as on every spread and pasteboard simultaniously!

                               

                              But this is not enough.
                              When introducing MSOs, Adobe forgot to expand "allPageItems" to all states of all MSOs, that are not active. The invisible states.
                              What makes this case really complex is the possibility of nesting MSOs inside MSOs. And that ad infinitum (or so), if you like ;-)

                               

                              I begged for including pageItems in none-active states of MSOs with "allPageItems()" more than a year ago in the Wish-Forum:

                              http://forums.adobe.com/message/4226772#4226772

                               

                              To my knowledge this has not happened yet.

                               

                               

                              So the question remains: how do we expand the scope of "allPageItems()" to none-active states of MSOs?

                               

                               

                              I have no easy answer, but there might be a couple of concepts:

                               

                               

                              1.a Export all pageItems to IDMS and search for buttons in the XML.
                              Identify there ID and get use of:

                               

                              myDocument.pageItems.itemByID(ID-Number);
                              

                               

                              to access them. The trick here is:
                              if you know the ID of an object, you can get it in every case, deeply nested or not, with itemByID(ID-Number).

                               

                              Yet I have no proof, if that is possible (or reliable).


                              In the same way:

                              1.b Export the document to IDML and search for buttons in the XML.

                               

                               

                              2. Make every state of every MSO the active state and go through with "allPageItems()" and evaluate all the pageItems you come across.
                              This might be a very complex thing.
                              Remember: MSOs could be nested inside MSOs

                               

                               

                              3. Find a way (a recursive function) that can step through all pageItems hunting for MSOs, all states, all MSOs in all objects of that states and hunting for buttons.

                               

                              With #3 I finally made a small progress, but I was interrupted with paid work for a couple of weeks.
                              So I cannot say, if I will succeed…

                               

                               

                               

                              Ok. This post is getting longer and longer. Let's see what your comments are on that subject.

                              Hopefully someone chimes in and has a solution for one of the three cases.
                              Or even a better one :-)

                               

                              Uwe

                              • 12. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                Kasyan Servetsky Level 5

                                Thanks, Trevor. Your new version is much more elegant.

                                Here's the same idea but a little different implementation:

                                var doc = app.activeDocument,
                                buttons = doc.buttons.everyItem().getElements(),
                                bt;
                                
                                for (var p = 0; p < buttons.length; p++) {
                                    bt = buttons[p];
                                    $.writeln("Button: " + bt.name + " -- Printable: " + CheckPrintable(bt));
                                }
                                
                                function CheckPrintable(button) {
                                    var printable,
                                    as = button.activeStateIndex;
                                
                                    if (as != 0) {
                                        button.activeStateIndex = 0;
                                        try {
                                            printable = button.printableInPdf;
                                        } catch (err) {
                                            printable = true;
                                        }
                                        button.activeStateIndex = as;
                                    }
                                    else {
                                        try {
                                            printable = button.printableInPdf;
                                        } catch (err) { 
                                            printable = true;
                                        }
                                    }
                                
                                    return printable;
                                }
                                

                                I used this function in the new version -- 1.3

                                • 13. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                  Kasyan Servetsky Level 5

                                  Hi Uwe,

                                   

                                  I started writing the “Export button description settings” script in response to this post.

                                  At my regular work I do mostly color correction and retouching for a printed magazine and have only basic idea about interactive documents, DPS, ePubs, MSO, etc. (Mostly by watching courses on Lynda) From time to time my customers ask me to write scripts to automate some processes and I learn what is needed on the fly. Usually I ask to give me a couple of sample documents (“before” and “after”) so I could see what should be done by script, and test it against this specific document. Ideally the client gives me the “real” documents so I could make sure that everything works properly.

                                  In this particular case I agreed to make a “quick & dirty” script for free. When I asked the guy to give me a sample, or a screenshot at least, he refused saying that he was not allowed to do this. (I guess he must be working for USSS or something.) Anyway, at the moment, I have no idea of how “a button that is part of a MSO” looks like. When (if) I have free time, I’ll look into this and will go further. But so far I tested it against a document I had at hand which was created by a script I wrote recently (it creates pop-up buttons from InDesign’s index). All the buttons are standalone objects there: no grouping, nesting, etc.

                                  For people using buttons extensively like the users of the ADPS or other Digital Publishing solutions for InDesign a script that lists all (or some) properties of all buttons in a document could be of immense help.

                                  DPS is a very interesting topic for me. It is not asked-for here in Ukraine (I know only about one really cool project made in the country by A-BA-BA-HA-LA-MA-HA Publishers). But I made a couple of scripts for folio projects (for a company In Russia): one for creating “navto” links and another for converting hyperlinks to buttons.

                                   

                                  Regards,
                                  Kas

                                  • 14. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                    Trevorׅ Adobe Community Professional

                                    Hi Kas and Uwe,

                                     

                                    The script in 12 above look good

                                    .

                                    Here's a cute script below. Worth looking at.

                                    I've made a re-cursive* function to find all the buttons, BUT-on my head I have doubts about it and will leave the testing for Uwe.

                                    Unfortunately I have not been interrupted with 2 weeks of paid work

                                    It's not very elegant or efficient as the results have to be filtered out.

                                    I didn't bother with finding the tougher properties like PDFPrintable

                                     

                                    I updated the document in the link above in post 6 to include multi-state objects.

                                    Export the document to a .swf file with html.

                                    Download the doc and run the bellow script.

                                    Click on the Button and MSO names in the UI and you can try the play movie button.

                                     

                                    P.s. My first question on scripting was answered by Kasyan, it was something like how to color a paragraph red.  Glad to say I've moved on a bit from then, Thanks Kas.

                                     

                                    Regards

                                     

                                    Trevor

                                     

                                     

                                    // Made By Trevor http://forums.adobe.com/message/5240408#5240408
                                    // TrevorsScript@Gmail.Com
                                    // DISACLAIMER - this script is completely no optamised with regards to speed  or accuracy, style etc. etc etc.
                                    // has not been tested properly and is not reflective of any pro scripts that I would be happy to do for money!!! 
                                    
                                    #targetengine Trevor
                                    var suil = app.scriptPreferences.userInteractionLevel,
                                    ser = app.scriptPreferences.enableRedraw;
                                    app.scriptPreferences.userInteractionLevel=UserInteractionLevels.INTERACT_WITH_ALL;
                                    app.scriptPreferences.enableRedraw =1;
                                    app.doScript("main()", ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Extract Combine and Resize Pages");
                                    app.scriptPreferences.userInteractionLevel= suil;
                                    app.scriptPreferences.enableRedraw = ser;
                                    function main ()
                                        {
                                            var doc = app.activeDocument, _button = app.activeDocument.buttons.everyItem().getElements(),
                                                  _pageItems = doc.allPageItems,l = _pageItems.length, as,  _printable,  n = 0, m = 0, b, c = 0, d = 0,
                                                  myMSOs = [], uniqueMSOsObj = {}, allMSOs = [], MSOnames = [], allMSOIds = [],
                                                  myButtons = [], uniqueButtonsObj = {}, allButtons = [], buttonNames = [], allButtonsIds = [];
                                    
                                             //  first get the simple buttons     
                                            while (l--)     if (_pageItems[l] instanceof Button) uniqueButtonsObj[_pageItems[l].id] = myButtons[n++] = _pageItems[l] else  if (_pageItems[l] instanceof MultiStateObject) uniqueMSOsObj[_pageItems[l].id] = myMSOs [m++] = _pageItems[l];
                                            // now get the tougher one
                                            var ll = myMSOs.length;
                                            if (myMSOs .length > 0) while (ll--) findThoseButtons (myMSOs [ll]);
                                            // filter out the duplicates and make them acceasable for the UI and what ever
                                            for (b in uniqueButtonsObj) {allButtons[c] = uniqueButtonsObj[b]; buttonNames [c] = uniqueButtonsObj[b].name; allButtonsIds[c++] = uniqueButtonsObj[b].id};
                                            for (b in uniqueMSOsObj) {allMSOs[d] = uniqueMSOsObj[b]; MSOnames [d] = uniqueMSOsObj[b].name; allMSOIds[d++] = uniqueMSOsObj[b].id};
                                    
                                            // **************************************************************
                                            // the  re - cursed function - not optimized !!!!! also don't know if it will get the lot of them ????? doubt it.
                                    
                                            function findThoseButtons(multiState)
                                                {
                                                        var masi = multiState.activeStateIndex,
                                                               _states = multiState.states.length;
                                                        while (_states--)
                                                            {
                                                                var myState = multiState.states[_states];
                                                                myState.active = true;
                                                                var ObjAPItems = myState.parent.allPageItems,      // nead to use parent here!!!
                                                                       msl = ObjAPItems.length;
                                                                while (msl--) 
                                                                    {
                                                                        if (ObjAPItems[msl] instanceof Button) uniqueButtonsObj[ObjAPItems[msl] .id] =myButtons[n++] = ObjAPItems[msl] 
                                                                        else  if (ObjAPItems[msl] instanceof MultiStateObject) 
                                                                            {
                                                                                myMSOs [m++] = ObjAPItems[msl] ;
                                                                                uniqueMSOsObj[ObjAPItems[msl].id] = ObjAPItems[msl] ;
                                                                                findThoseButtons(ObjAPItems[msl]) ;
                                                                            }
                                                                       }
                                                               }
                                                    multiState.states[masi].active = true;
                                                }
                                            // ***************** END OF FUNCTION *************************************
                                    
                                            // *********************************************************************
                                            //          SUI by me
                                            //          This is quite nice if I say so myself :-) puts the window on the right 1/5 of the page
                                            var sb = $.screens[0],
                                            pannelBounds = [4*(sb.right-sb.left)/5, sb.top + 38, sb.right - 10, sb.bottom - sb.top],
                                            pannelHeight = pannelBounds[3] - pannelBounds[1], 
                                            pannelWidth = pannelBounds[2] - pannelBounds[0], 
                                            heightGap = pannelHeight/100,
                                            widthGap = pannelWidth/100,
                                            w = new Window ("palette", "Button Info", pannelBounds),
                                            myButtonList = w.add ("listbox", [widthGap ,heightGap, pannelWidth - widthGap, 24 * heightGap], buttonNames, {multiselect: false, }),
                                            myMSList = w.add ("listbox", [widthGap ,heightGap * 25, pannelWidth - widthGap, 48 * heightGap], MSOnames, {multiselect: false, }),
                                            makeReport = w.add ("editText", [widthGap ,heightGap * 49, pannelWidth - widthGap, 90 * heightGap],undefined, {multiline:true}),
                                            makeMovie = w.add ("button",[widthGap ,heightGap * 91, pannelWidth - widthGap, 98 * heightGap], "Play Movie");        
                                            // *************
                                            myButtonList.onChange = function ()
                                            {
                                                allButtons[myButtonList.selection.index].select(); 
                                                myMSList.selection = null;
                                                var objReport = "", x;
                                                for (x in allButtons[myButtonList.selection.index])
                                                    {
                                                        objReport += (x + " : " );
                                                       try { objReport += uniqueButtonsObj[allButtonsIds[myButtonList.selection.index]][x] + "\r" }
                                                       catch (e) { objReport += "\rERROR\r" + e + "\r************\r";}
                                                       // Sorry if you want the complicated results you can combine with the script in the post above do some DIY
                                                     };
                                                makeReport.text = objReport;
                                            }
                                            // *************
                                            myMSList.onChange = function ()
                                            {
                                                allButtons[myMSList.selection.index].select(); 
                                                myButtonList.selection = null;
                                                var objReport = "", x;
                                                for (x in allButtons[myMSList.selection.index])
                                                    {
                                                        objReport += (x + " : " );
                                                       try { objReport += uniqueMSOsObj[allMSOIds[myMSList.selection.index]][x] + "\r" }
                                                       catch (e) { objReport += "\rERROR\r" + e + "\r************\r";}
                                                       // See the above annotation
                                                     };
                                                makeReport.text = objReport;
                                            }
                                            // *************
                                            makeMovie.onClick = function () // make movie
                                            {
                                                for (var _frame = 0;  _frame<buttonNames.length; _frame++)
                                                    {
                                                        allButtons[_frame].select();
                                                        $.sleep(250);
                                                     }
                                                for (var _frame = 0;  _frame<MSOnames.length; _frame++)
                                                    {
                                                        allMSOs[_frame].select();
                                                        $.sleep(250);
                                                     }
                                            }
                                            w.show ();           
                                        }
                                    // ************ THE END ***************
                                    

                                     

                                     

                                    *re-cursive joke courtesy of Jongware

                                    1 person found this helpful
                                    • 15. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                      Laubender Adobe Community Professional & MVP

                                      @Trever – impressive…

                                      CONGRATULATIONS!

                                       

                                      All buttons found in my test files!
                                      I will test harder ;-)

                                       

                                      And examine your script more closely.

                                       

                                      I mean, it seems there is a small bug in the UI part of the script:
                                      The names of the listed MSOs are right, but if I click on of the names a button instead of a MSO is selected.

                                       

                                      GREAT!

                                       

                                      Uwe

                                      • 17. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                        Trevorׅ Adobe Community Professional

                                        Hi All

                                         

                                        Thanks for the testing Uwe, I am waiting in trepidation for the harder ones. I must say I'm quite suprised that so far I've passed.

                                        Regarding the UI bug that is very well explained by the 3rd and 4th lines of the script (from the very top) !

                                        That section of the script was done last and was done on a type and post basis.

                                        This should be changed to

                                                // *************
                                                myMSList.onChange = function ()
                                                {
                                                    allButtons[myMSList.selection.index].select();

                                        This

                                                // *************
                                                myMSList.onChange = function ()
                                                {
                                                    allMSOs[myMSList.selection.index].select();

                                         

                                        I am convinced that the recusive function is inefficient and plan to send a PM to someone who might like do a better job.

                                         

                                        P.s. Come on Kasyan, you can allocate a correct

                                        • 18. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                          Marc Autret Level 4

                                          Hi ~Trevor~,

                                           

                                          What I don't understand in your code is the need to successively activate the hidden states to access the enclosed items from the parent MSO.

                                          But that's probably because I definitely don't master those interactive objects.And, as Uwe said, there are countless ways to hide a MSO in the DOM hierarchy. So I'm not confident in the code I propose. Anyway, since you asked for suggestions, here's how I would have *naively* addressed the scanning routine:

                                           

                                          var registerStateContainer = function(/*FormField*/ff, /*str*/k, /*{k=>{...}}&*/o)
                                          // -------------------------------------
                                          // ff must be a 'state container' (i.e. either a Button, or a MSO)
                                          {
                                              if( o.hasOwnProperty(k) ) return;
                                              o[k] = {
                                                  type:    ff.__class__,
                                                  name:    ff.name,
                                                  states: ff.states.length,
                                                  // etc.
                                                  };
                                          };
                                          
                                          var scanStateContainers = function F(/*PageItem[]&*/a, /*{_id=>{...}}&*/o)
                                          // -------------------------------------
                                          {
                                              // Caching IDs already explored
                                              // ---
                                              F.cache || (F.cache={});
                                          
                                              // Vars
                                              // ---
                                              var subs = [],
                                                  k, t, SC;
                                          
                                              while( t=a.pop() )
                                                  {
                                                  k = '_' + t.id;
                                          
                                                  if( F.cache.hasOwnProperty(k) ) continue;
                                          
                                                  (SC = ('states' in t)) && registerStateContainer(t, k, o);
                                                  
                                                  subs = subs.concat( SC ?
                                                      t.states.everyItem().pageItems.everyItem().getElements() :
                                                      t.allPageItems );
                                                  
                                                  F.cache[k] = null;
                                                  }
                                          
                                              subs.length && F(subs,o);
                                              subs = t = null;
                                          };
                                          
                                          // Main
                                          // ---
                                          var doc = app.activeDocument,
                                              results = {};
                                          
                                          scanStateContainers(doc.allPageItems, results);
                                          
                                          alert( results.toSource() );
                                          
                                          // ---
                                          // Then you can traverse results using for..in
                                          // Also, if you need to access any state container
                                          // (including nested), itemByID should always work:
                                          // doc.formFields.itemByID(parseInt(key.substr(1),10))
                                          // ---
                                          

                                           

                                          @+

                                          Marc

                                          1 person found this helpful
                                          • 19. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                            Kasyan Servetsky Level 5

                                            I want to thank everybody who replied to my post. My original question has been answered so I mark the thread as “Answered”.

                                             

                                            Let’s sum up:

                                            If the printableInPdf property wasn’t changed by the user/script, it throws the error while trying to access it. In this case we set it to true in the “on error” block because that’s the default value for every button.

                                             

                                            My special thanks for the examples in posts 14 (Trevor) and 18 (Marc). I need some time to digest the information.

                                            • 20. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                              Trevorׅ Adobe Community Professional

                                              Hi Marc and all

                                               

                                              Firstly thank you Marc for your speedy reply to my PM at somewhat of an unearthly hour.  I very much appreciate it.

                                              I had no doubt that your code would be original with a lot to learn from it.

                                               

                                              You have some very interesting techniques here and as Kasyan put it so beautifully "I need some time to digest the information."

                                              It would seem that the script is (quite easily?) adaptable to find other tricky items.

                                               

                                              One thing that looks like it to me is that if one just wanted to find only buttons and not all the multistate objects then one would just change the line

                                              (SC = ('states' in t)) && registerStateContainer(t, k, o);

                                              to

                                              (SC = ('states' in t)) && t.constructor.name == 'Button' && registerStateContainer(t, k, o);

                                               

                                              Not that I can understand too much at present of your script (I will try hard to get to the bottom of it over the next week) but  the line

                                              F.cache || (F.cache={});

                                              is particularly bewildering to me

                                              Could you please explain it.

                                               

                                              Regarding activating the states in my script. #14

                                              As is I don't think there's any need for it.  My experience with MSOs is I think average amongst the community here having never used scripted or seen one prior to this thread!

                                               

                                              I put it in because of the original question of how to get the printableInPdf property which does look like the active state needs to set to 0 to get an accurate property - see post 5,6 and 7 above.  I thought that if there are buttons in deferent states of the MSOs then I would have to loop through the states of the MSO and activate the button 0 state of each MSO to get the correct result. I must say things are a bit fuzzy.

                                               

                                              Regards

                                               

                                              ~Trevor~

                                              • 21. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                                Kasyan Servetsky Level 5

                                                @Trevor

                                                Not that I can understand too much at present of your script (I will try hard to get to the bottom of it over the next week) but  the line

                                                F.cache || (F.cache={});

                                                is particularly bewildering to me

                                                Could you please explain it.

                                                See here.

                                                • 22. Re: [JS CS6] Is anybody able to get button’s printableInPdf property?
                                                  Trevorׅ Adobe Community Professional

                                                  Thanks for the link Kasyan, and also thanks for asking the question in the first place, I learnt a lot from this thread.

                                                   

                                                  I now have every line of Marcs code figured out.

                                                  If anyone is interested in seeing my lengthy annotations you can see them here.

                                                   

                                                  Regarding the F.cache || (F.cache={}); line it's purpose is to create a private memory store as an object - prototype of the function F if and only if it does not exist in that targetengine.  As such different results could be produced by re-running a script in a main indesign target engine than re-running it in a "session" target engine or a main ESTK targetengine.  In the blow example this is not the case.

                                                   

                                                  myName = "Bloggs";
                                                  myName || (myName = "Smith"); // will not get set to "Smith" because a value has already been allocated
                                                  alert(myName); // >= Bloggs
                                                  myName = null;
                                                  myName || (myName = "Trevor"); // will  get set to "Smith" because myName has no value
                                                  alert(myName); // >= Trevor
                                                  

                                                   

                                                  @ Marc, Thank you again for spending the time to script a solution, I learnt a lot from it and I'm sure it's more efficient than my one.

                                                   

                                                  Trevor