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

Ignore pasteboard contents

Contributor ,
Jun 02, 2015 Jun 02, 2015

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

TOPICS
Scripting
1.4K
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

Enthusiast , Jun 03, 2015 Jun 03, 2015

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.parentTextFrames[0].parentPage != null)

    {

        found.select();

        alert("Your further code process goes here...")

    }

}

app.findTextPreferences = NothingEnum.nothing;

app.changeTextPreferences = NothingEnum

...
Translate
Advisor ,
Jun 02, 2015 Jun 02, 2015

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

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
Contributor ,
Jun 02, 2015 Jun 02, 2015

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?

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 Expert ,
Jun 02, 2015 Jun 02, 2015

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

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
Contributor ,
Jun 02, 2015 Jun 02, 2015

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

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 Expert ,
Jun 02, 2015 Jun 02, 2015

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

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
Contributor ,
Jun 02, 2015 Jun 02, 2015

Ok thank you...

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
Contributor ,
Jun 03, 2015 Jun 03, 2015

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

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
Contributor ,
Jun 03, 2015 Jun 03, 2015

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

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
Enthusiast ,
Jun 03, 2015 Jun 03, 2015

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.parentTextFrames[0].parentPage != null)

    {

        found.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(_){} 

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
Contributor ,
Jun 03, 2015 Jun 03, 2015
LATEST

Hi,

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

- Sudha K

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