8 Replies Latest reply on Oct 27, 2011 8:34 AM by hjaecklein@vogel-druck.de

    Quick apply using javascript

    xmlapi Level 1

      How do you quick apply using javascript? I looked at the API but did not see a property or method.

        • 1. Re: Quick apply using javascript
          REVA83 Level 1

          Hello xmlapi,

           

          Already Quick Apply is a simplified method. Moreover what are you going to automate or simplify with the Quick Apply using javascript?

          • 2. Re: Quick apply using javascript
            xmlapi Level 1

            The problem is that I'm using Smart Text reflow to delete empty pages.Smart Text reflow only deletes pages when Indesign is "idle". This means, when the script has finished executing, smart text reflow will slowly start deleting pages etc.

             

            Quick Apply has a option under Text and Tables > Recompose all stories immediately which forces smart text reflow to run and delete all empty frames immediately.

             

            How do I trigger this using javascript?

             

            I tried:

            for(var i=1; i < doc.Stories.Count; i++)

            {

                doc.Stories[i].Recompose();

            }

             

            The above code doesn't work because the recompose method tells Indesign to recompose it BUT Indesign doesn't do it until it is idle.

             

             

            The quick apply option does it immediately so how do I trigger that quick apply option in javascript OR how do I get it to recompose immediately?

            • 3. Re: Quick apply using javascript
              Dirk Becker Level 4

              > the recompose method tells Indesign to recompose it BUT Indesign doesn't do it until it is idle

               

              have you experienced that yourself? I'm using doc.recompose() all day from within scripts, and it is executed immediately. As a side effect it is very handy to update the layout window while single stepping.

               

              Anyway, QuickApply is a UI feature that in your case allows to look up menu actions by name. It also supports other entities (styles etc.) but that's irrelevant here. To find the name of all menu actions known to the application, run this in ESTK, and grab the output from the console:

               

              app.menuActions.everyItem().name.join("\n")

               

              Then pick your choice:

               

              app.menuActions.itemByName("Recompose all stories immediately").invoke();

               

              Dirk

              • 4. Re: Quick apply using javascript
                xmlapi Level 1

                Thanks for the response.

                 

                1) Are you using Indesign Desktop or Server?

                2) What version? Are your documents "visible" if you're using Desktop (the showingoptions parameter in the app.Open set to true)?

                 

                I'm using Desktop CS5 (7.0) and I've tried recompose (stories, textframes, document) in both C# and javascript, neither one recomposes immediately. It only recomposes when I view the particular page in Indesign. After I view, 1-2 seconds later Indesign does the recompose.

                • 5. Re: Quick apply using javascript
                  Dirk Becker Level 4

                  As we were talking UI features here, I was using InDesign CS 4 and 5 Desktop.

                   

                  My experiences with recompose() are mainly on CS4, both Server and Desktop. Actually on InDesign Server I have several occasions where recompose() makes a difference - namely the geometric bounds of anchored objects which are not available as long composition is pending ... Just getting other properties will also force composition, e.g. the "overflows" property.

                   

                  On InDesign Desktop my documents are showing - that is used for debugging anyway.

                   

                  I have not made that clear and don't know whether it matters - unlike your earlier post, I usually go thru document.recompose() while you mentioned story.recompose(). On the other hand an occasional story.recompose() may also have sneaked in.

                   

                  Dirk

                  • 6. Re: Quick apply using javascript
                    xmlapi Level 1

                    Interesting. On mine, document.recompose() or any other recompose has zero effect on smart text reflow.

                     

                    Does the "delete feature" of the smart text reflow also work (immediately) when you recompose? It doesn't on mine (desktop). I'm guessing it's some sort of config/bug.

                    • 7. Re: Quick apply using javascript
                      Dirk Becker Level 4

                      I really should stop posting when I'm tired to fully read the original message.

                       

                      My focus is on single page documents where the composer also can be an issue but I do not need the Smart Text Reflow feature, which is dependent on composition so it comes even later. Actually I have not used it in years and had to look up how to prepare a document and find out what's going on. Btw, internally the feature is called AutoFlow.

                       

                      If deleting pages is your issue, you can easily do it by script, but I understand if you prefer to utilize the builtin feature ...

                       

                      var ts = app.activeDocument.stories.lastItem(); // use your story

                      if( !ts.overflows ) {

                          var lastIP = ts.insertionPoints.lastItem();

                          var lastTF = lastIP.parentTextFrames[0];

                          for( var emptyTF=lastTF.nextTextFrame; emptyTF; emptyTF=lastTF.nextTextFrame ) {

                             var emptyPage = emptyTF.parent;

                             emptyPage.remove();

                          }

                      }

                       

                      Dirk

                      • 8. Re: Quick apply using javascript
                        hjaecklein@vogel-druck.de

                        Hello xmlapi,

                         

                        did you try a 'showText()' instead of 'recompose()' ?