Copy link to clipboard
Copied
Hello,
I'm struggling with the following things:
I need to check a document to see if it contains any hidden characters. Do i have to create a loop and check each of the characters? Because with a big document it is impossible to do. Or is there an easier way to do it?
2nd question is that i need to check if any of the character styles have been overriden, i have yet to find a way to do this so any help would be highlyappreciated.
Hi Pete,
I think I've come up with a nice technique here if I say so myself it can be utilized for umpteen properties. To find them very quickly
I actually think this is one of the best scripts I've written (by far no the most complicated but I think very efficient)
JONGWARE this time I think I got the textStyleRanges right!
What a pity that Vincent appears to have passed away, I definitely deserve some points for this one IMHO!
Regards to all and may Vincent RIP,
Trevor
...// Script by Trevor to make
Copy link to clipboard
Copied
Hi Vincent
Can you explain what you mean by hidden characters (the are quite a few possibilities)
Copy link to clipboard
Copied
Regarding the character style override see if http://in-tools.com/article/scripts-blog/showing-text-formatting-overrides/
meets your needs
Copy link to clipboard
Copied
and even more cool is Marc's script:
http://www.indiscripts.com/post/2012/05/the-hidden-way-to-highlight-style
Copy link to clipboard
Copied
Vamital,
Jives (or you) messed up your link so here it is again. (compare the style(s) at the end)
http://www.indiscripts.com/post/2012/05/the-hidden-way-to-highlight-styles
Marc's Basic version as refered to in the link to Harbs' is here
http://www.indiscripts.com/post/2010/05/show-local-formatting-in-indesign-cs4
Hope these work
Trevor
Copy link to clipboard
Copied
Very neat !
But is there a quick way for ascript to scan all the text in a story for only those textRuns which override either a paragraph or character style -- without doing the entire compare all the attributes thing?
I don't want to see the results on the screen, but rather find them in a script.
Thanks !
Copy link to clipboard
Copied
You could try a custom Preflight profile. I think there is an item "local overrides" for that.
It should be pretty fast, but the hard part is going to be parsing the returned results 🙂
Copy link to clipboard
Copied
Interesting idea. Thanks
Copy link to clipboard
Copied
Hi Pete,
I think I've come up with a nice technique here if I say so myself it can be utilized for umpteen properties. To find them very quickly
I actually think this is one of the best scripts I've written (by far no the most complicated but I think very efficient)
JONGWARE this time I think I got the textStyleRanges right!
What a pity that Vincent appears to have passed away, I definitely deserve some points for this one IMHO!
Regards to all and may Vincent RIP,
Trevor
// Script by Trevor to make an array quickly of Overridden Text Styles
// http://forums.adobe.com/message/4853747#4853747
#target indesign
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "List Overridden Text Styles");
function main()
{
var doc = app.activeDocument, myOverRiddendTextStyleRanges = [], l,
myOverRiddenStyleFlags = doc.stories.everyItem().textStyleRanges.everyItem().styleOverridden;
var myTextStyleRanges = doc.stories.everyItem().textStyleRanges.everyItem().getElements();
l = myOverRiddenStyleFlags.length;
while (l--) (myOverRiddenStyleFlags
) ? myOverRiddendTextStyleRanges.push(myTextStyleRanges ) : 0; // we now have an array of all the overridend Text Ranges // For the Sake of the Alert but not neaded otherwise
l = myOverRiddendTextStyleRanges.length;
var overRiddenContents = [];
while (l--) overRiddenContents.push(myOverRiddendTextStyleRanges
.contents); alert (overRiddenContents)
}
Copy link to clipboard
Copied
~ Trevor ~ wrote:
I think I've come up with a nice technique here if I say so myself it can be utilized for umpteen properties. To find them very quickly
I actually think this is one of the best scripts I've written (by far no the most complicated but I think very efficient)
Blah, Blah, Blah
Drat, Drat, Drat!!! Darn! Egg on face!!!
I was sure that using
myOverRiddenStyleFlags = doc.stories.everyItem().textStyleRanges.everyItem().styleOverridden;
while (l--) (myOverRiddenStyleFlags
) ? myOverRiddendTextStyleRanges.push(myTextStyleRanges ) : 0;
would be a lot quicker than using
while (l--) (myTextStyleRanges
.styleOverridden) ? myOverRiddendTextStyleRanges.push(myTextStyleRanges ) : 0;
well it's not. It is actually slower.
On a nearly 600 page document with several thousand overrides the script took about 74 seconds to run (including making an array of the contents but not displaying it) when not using the flags and about 100 second when using them
So this is not one of the best scripts that I have written at all and my newly discovered technique is pretty rubbish.
Oh well, back to the drawing board.
Anyway here's the boring old script using the good old convectional methods.
// Script by Trevor to make an array quickly of Overridden Text Styles
// http://forums.adobe.com/message/4853747#4853747
#target indesign
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "List Overridden Text Styles");
function main()
{
var startTime = new Date().getTime(); // removable if the time alert below is removed
var doc = app.activeDocument, myOverRiddendTextStyleRanges = [], l,
//myOverRiddenStyleFlags = doc.stories.everyItem().textStyleRanges.everyItem().styleOverridden;
myTextStyleRanges = doc.stories.everyItem().textStyleRanges.everyItem().getElements();
l = myTextStyleRanges.length;
while (l--) (myTextStyleRanges
.styleOverridden) ? myOverRiddendTextStyleRanges.push(myTextStyleRanges ) : 0; // For the Sake of the Alert but not neaded otherwise
l = myOverRiddendTextStyleRanges.length;
var overRiddenContents = [];
while (l--) overRiddenContents.push(myOverRiddendTextStyleRanges
.contents); alert ("Script took "+(new Date().getTime()-startTime)/1000+" seconds"); // removable
// alert (overRiddenContents) // if there are a very lot of overRiddenContents this line can be problematic that's why it's escaped.
}
Copy link to clipboard
Copied
Hey hey,
I'm still very much alive . For some reason the login button was redirecting me to a 404 page instead of actually logging me in .
Thanks for the many replies. I can definitly use the script for the overriden textstyles. Thank you for this Trevor.
As for the hidden characters. I just want to find out is the document contains any hidden character. I dont need it to say which or where, just a true or a false.
Maybe i'm not reasoning correctly but as far as i know you need to check every character and check if its a hidden character or not. Is this the correct way?
And while i'm at it. I have one more for you guys, is there an easy way to get the dimensions of a page? I've looked through the API but couldnt find any easy way to find out (it's probably me thou). The way i'm doing it now is the following:
pageWidth = Math.ceil(currentPage.bounds[3] - currentPage.bounds[1]);
pageHeight = Math.ceil(currentPage.bounds[2] - currentPage.bounds[0]);
I have a feeling that this isn't the right way at all.
Finally i want to say thanks for the replies. Good to know there are other people that are making plugins and that i'm not on my own.
Copy link to clipboard
Copied
Hi Vincent
Thrilled to here you are still with us.
I'm still not clear on what you are referring to be hidden characters.
Do you mean
1) Overflowing text which you can't see
2) Space like characters which you can't see
3) Hidden conditional text characters which you can't see
4) Some other type of thing that you can't see.
Copy link to clipboard
Copied
5) The hidden characters refered to in the view options as in these http://indesignsecrets.com/downloads/guide_specialchars-2012.pdf
P.s. I meant to say above
Thrilled to hear you are still with us.
Copy link to clipboard
Copied
Seems there was a miscommunication about this, i dont have to check for this after all. Do you have any ideas about the page dimensions Trevor?
Copy link to clipboard
Copied
I would do it the way you do it, maybe without the ceil
Glad you got your answers
Please mark as correct
Trevor
Copy link to clipboard
Copied
Will do, kind of new to this
Copy link to clipboard
Copied
vincent 1982 wrote:
And while i'm at it. I have one more for you guys, is there an easy way to get the dimensions of a page? I've looked through the API but couldnt find any easy way to find out (it's probably me thou). The way i'm doing it now is the following:
pageWidth = Math.ceil(currentPage.bounds[3] - currentPage.bounds[1]);
pageHeight = Math.ceil(currentPage.bounds[2] - currentPage.bounds[0]);
I have a feeling that this isn't the right way at all.
It depends. If your page sizes may differ from one page to another, yours is a good way. If you are pretty sure all pages are the same size (or they should be), you could also use http://jongware.mit.edu/idcs6js/pc_DocumentPreference.html#pageHeight and #pageWidth. Theoretically, this should be the same values. The 'page bounds' are particularly useful when you are dealing with spreads.
Copy link to clipboard
Copied
Back to the overridden characters thing. When using the textStyleRanges you can see if a certain style is overridden. But would it be possible to see which style is overridden? Wether it was a character style or a paragraph style? The reason i ask is that i have textStyleRanges in a document that has an appliedCharacterStyle aswell as a appliedParagraphStyle, but how can i know which of the 2 is the one that is overridden?