Copy link to clipboard
Copied
Hello All,
well, i'm dealing with huge number of inDesign files and the client wants to translate specific pages and to do that i have to set all text in excluded pages to be conditional text.
and that takes a lot of time from me to go through pages and select every text frame in excluded pages and set it to conditional text.
so i'm thinking if possible to do it with scripting method for ex.
i hope that it can be done because it will save a lot of time for me, and any help will be more highly appreciated really
PS: text in table should be conditional text too if it exists in excluded pages
Thanks in advance
Cheers
Suzan
Here you go with a merged code
You will get a prompt on running this code, for individual pages use the string in the format
1,2,4,8
For a range of pages use
1-5
...var pgRange = Window.prompt("Enter the page Range")
var pglist = []
if(pgRange.indexOf("-") != -1)
{
var temp = pgRange.split("-")
for(var i = temp[0] ; i <= temp[1]; i++)
pglist.push(i)
}
else
pglist = pgRange.split(',')
for(var j = 0; j < pglist.length; j++)
{
var index = pglist
- 1 for(var i = 0; i < app.documents[0].page
Copy link to clipboard
Copied
i'm thinking to edit the below script to apply conditional text (Hide) based on pages number instead of paragraph styles, but unfortunately i failed
applyCondition();
function applyCondition(){
var myParaStyle = 'Test';
app.findTextPreferences.appliedParagraphStyle = myParaStyle;
var found = app.documents[0].findText();
var c = 0;
while(c < found.length){
found
.paragraphs.everyItem().appliedConditions = app.documents[0].conditions.item('Hide'); c++;
}
}
Copy link to clipboard
Copied
any hint why this code doesn't work to me?
app.documents[0].pages[3].allPageItems.appliedConditions = app.documents[0].conditions.item('Hide');
i created a new condition with name "Hide" then tried to apply it on all items on page 3. can some one help please!
Copy link to clipboard
Copied
Hi Suzan,
Conditions can be applied on text and not on pageitems, so you will have to do something like the following
app.documents[0].pages[3].textFrames.everyItem().texts.everyItem().appliedConditions = app.documents[0].conditions.item('Hide');
-Manan
Copy link to clipboard
Copied
Hi Manan,
really i couldn't find enough words to express my appreciation to your kindly help, you made my day and saved me from huge manual work
your modification works great like magic but there are still two missing points don't work well and that's my fault for not mentioning them.
please can you help about that, i will be more appreciated
Thanks in advance
Cheers
Suzan
Copy link to clipboard
Copied
and just one more thing, the code applies on only one page
what about if i need to put a range of pages like from 1 to 10
or
specific pages like 1,4,6,8,9
i'm sorry if i'm bothering you with my questions but please forgive my curiosity
Suzan
Copy link to clipboard
Copied
Hi Suzan,
The overset and grouped issue can be resolved with the following
for(var i = 0; i < app.documents[0].pages[0].allPageItems.length; i++)
if(app.documents[0].pages[0].allPageItems.constructor.name == "TextFrame")
app.documents[0].pages[0].allPageItems.parentStory.texts.everyItem().appliedConditions = app.documents[0].conditions.item('Hide');
-Manan
Copy link to clipboard
Copied
Hi Susan,
For specific pages you could take the code mentioned above and just wrap it in a loop, and define an array of the pages you want it to be applied to. For Example:
var pagesToApplyTo = [ 1, 4, 6, 8, 9];
for ( var i = 0; i < pagesToApplyTo.length; i++)
{
app.documents[0].pages[pagesToApplyTo]..... // I haven't copied all the code, but hopefully you get the idea
}
The above code would apply your change to each of the pages in the pagesToApplyTo array.
( I am investigating the other questions you have)
Hope this helps
Malcolm
Copy link to clipboard
Copied
Hi Malcolm,
THAT IS MAGNIFICENT , and works great for me. i appreciate your support for this part really.
Hi Manan,
as always and said before you saved my day , you did the missing points right.
i'm thanking both of you again and again. can someone please merge the final two codes because i couldn't and don't know why . still beginner .
Suzan
Copy link to clipboard
Copied
Here you go with a merged code
You will get a prompt on running this code, for individual pages use the string in the format
1,2,4,8
For a range of pages use
1-5
var pgRange = Window.prompt("Enter the page Range")
var pglist = []
if(pgRange.indexOf("-") != -1)
{
var temp = pgRange.split("-")
for(var i = temp[0] ; i <= temp[1]; i++)
pglist.push(i)
}
else
pglist = pgRange.split(',')
for(var j = 0; j < pglist.length; j++)
{
var index = pglist
- 1 for(var i = 0; i < app.documents[0].pages[index].allPageItems.length; i++)
if(app.documents[0].pages[index].allPageItems.constructor.name == "TextFrame")
app.documents[0].pages[index].allPageItems.parentStory.texts.everyItem().appliedConditions = app.documents[0].conditions.item('Hide');
}
P.S. :- Have not added to much error handling, like mixing the string formats will not work. But if you stick with one format at a time it should work just fine
-Manan
Copy link to clipboard
Copied
Nice! But change those lines 3..9 to this single one
pgRange = pgRange.replace(/(\d+)-(\d+)/g, function(a,b,c) { a = b; b = Number(b); c = Number(c); for (b++; b<=c; b++) a+=','+b; return a});
so you don't need to worry about mixing ranges, such as '1-5,8,12-15' -- this gets translated to '1,2,3,4,5,8,12,13,14,15', and you can split on the commas afterwards.
Copy link to clipboard
Copied
Excellent [Jongware], i just looked up to know that replace can take a function as an argument as well. Quite neat
-Manan
Copy link to clipboard
Copied
Manan Joshi YOU ARE THE MAN
and thanks Jongware for your brilliant touch
Kindly regards for all who helped.
Cheers
Suzan
Copy link to clipboard
Copied
I have silimilar request and I think it would be usefull for original poster as well. Ofcourse I am talking about post translation scripting. Anyhow, could you please make a script that will make visable "conditional text" "styles" that are marked as hidden (not visable)?
Thanks.