10 Replies Latest reply on Jun 3, 2015 9:02 PM by Sudha K

    Ignore pasteboard contents

    Sudha K Level 1

      Hi,

       

         When I find the contents from InDesign document, it gives the content from pasteboard also.  But I need to get the content from only pages.  How can i get the page contents alone. 

       

        Can anyone help me?

       

      Thanks in advance,

      Sudha K

        • 1. Re: Ignore pasteboard contents
          Vamitul Level 4

          something like:
          doc.pages.everyItem().pageItems.everyItem().getElements() might work.

          • 2. Re: Ignore pasteboard contents
            Sudha K Level 1

            Hi,

             

              Thanks.  It will return all page items. I am finding contents using paragraphs style in multiple documents. Can i use pages items loop? it does not affect the progress of the process?

            • 3. Re: Ignore pasteboard contents
              Laubender Adobe Community Professional & MVP

              Hi Sudha,

              depending on the strategy how you are doing your Search/Replace, you can do the following:

               

              1. Lock all page items in the document

              2. Unlock all page items on the pages of the document

              3. Do a TEXT Search/Replace or a GREP Search/Replace

              4. Unlock all page items in the document

               

              //1.Lock all page items in the document
              app.documents[0].pageItems.everyItem().locked = true;
              
              //2. Unlock all page items on the pages of the document
              app.documents[0].pages.everyItem().pageItems.everyItem().locked = false;
              
              //3.Put in here your Search/Replace function with GREP Search/Replace functionality:
              myFancySearchReplaceFunction();
              
              //4. Unlock all page items in the document
              app.documents[0].pageItems.everyItem().locked = false;
              
              function myFancySearchReplaceFunction(){
              //Put in here your code
              //This is just a dummy function
              };
              

               

              This code is for one single document.

              You could do it for all documents open using a loop. Or try to expand the scope of your search/replace function (you did not provide the code) to all open documents and instead of documents[0] you could use the app.documents.everyItem() approach. Or you could open all documents of a specific folder one after another, do the search/replace, save and close the doc and then start with the next one using a loop.

               

              Uwe

              • 4. Re: Ignore pasteboard contents
                Sudha K Level 1

                Thank you.... Will it ignore pasteboard contents?

                 

                Need any check for any objects are locked in pages??

                 

                        var  found = 0;

                        app.findTextPreferences = NothingEnum.nothing;

                        app.changeTextPreferences = NothingEnum.nothing;

                        app.findChangeTextOptions.caseSensitive = false;

                        app.findChangeTextOptions.includeFootnotes = true;

                        app.findChangeTextOptions.includeHiddenLayers = true;

                        app.findChangeTextOptions.includeLockedLayersForFind = true;

                        app.findChangeTextOptions.includeLockedStoriesForFind = true;

                        app.findChangeTextOptions.includeMasterPages = true;

                        app.findChangeTextOptions.wholeWord = false;

                       

                    

                      app.findTextPreferences.appliedParagraphStyle = style;

                      found = app.activeDocument.findText();

                                   

                       app.findTextPreferences = NothingEnum.nothing;

                       app.changeTextPreferences = NothingEnum.nothing;

                 

                 

                Also wat abt these options??

                         app.findChangeTextOptions.includeLockedLayersForFind = true;

                        app.findChangeTextOptions.includeLockedStoriesForFind = true;

                 

                 

                - Sudha K

                • 5. Re: Ignore pasteboard contents
                  Laubender Adobe Community Professional & MVP

                  I'd say, just try it in a test document with some text frames on the pasteboard and some text frames on the pages.

                   

                  Uwe

                  • 6. Re: Ignore pasteboard contents
                    Sudha K Level 1

                    Ok thank you...

                    • 7. Re: Ignore pasteboard contents
                      Sudha K Level 1

                      I tested this code. It returns text from locked pageitems when using findtext  preferences.   So i could not able to ignore pasteboard items text.

                       

                       

                       

                      - Sudha K

                      • 8. Re: Ignore pasteboard contents
                        Sudha K Level 1

                        Found the cleanup pasteboard script from the below site.

                         

                        http://www.indiscripts.com/post/2009/09/clean-up-your-pasteboard

                         

                        Its working fine for InDesign CS4 but not for CS6.

                         

                        - Sudha K

                        • 9. Re: Ignore pasteboard contents
                          Sajeev Sridharan Level 4

                          To ignore pasteboard content try this:

                           

                          app.findTextPreferences = NothingEnum.nothing;
                          app.changeTextPreferences = NothingEnum.nothing
                          app.findTextPreferences.appliedParagraphStyle = "sajeev";
                          found = app.activeDocument.findText();
                          for(var i=0; i<found.length; i++)
                          {
                              if(found[i].parentTextFrames[0].parentPage != null)
                              {
                                  found[i].select();
                                  alert("Your further code process goes here...")
                              }
                          }
                          app.findTextPreferences = NothingEnum.nothing;
                          app.changeTextPreferences = NothingEnum.nothing
                          

                           

                          To clean-up paste board content (Developed by Marc Autret):

                           

                          removePasteboardItems(app.documents.length && app.activeDocument);
                          function removePasteboardItems(/*?Document*/doc)  
                          {  
                              if( !doc ) return;  
                                var items = doc.pageItems.everyItem().getElements(),  
                                  t = null;  
                                while( t=items.pop() ) t.parentPage || removeItem(t);  
                                t = items = null;  
                          }  
                            
                          function removeItem(/*PageItem*/item)  
                          {  
                              try {  
                                  item.locked = false;  
                                  item.remove();  
                                  }  
                              catch(_){}  
                          }  
                          
                          
                          • 10. Re: Ignore pasteboard contents
                            Sudha K Level 1

                            Hi,

                             

                            Thank you... Its working for me...

                             

                            - Sudha K