Copy link to clipboard
Copied
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
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
Copy link to clipboard
Copied
something like:
doc.pages.everyItem().pageItems.everyItem().getElements() might work.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Ok thank you...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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(_){}
}
Copy link to clipboard
Copied
Hi,
Thank you... Its working for me...
- Sudha K
Find more inspiration, events, and resources on the new Adobe Community
Explore Now