Nice job. Thank you for sharing.
cool script, thanks for publishing it!
funny enough i'm planning/writing a similar script at the moment. i focus on a solution for handling text attributes via font styles, because a lot of our sources uses them and not the electronic text attributes.
i'm not sure about the handling (there are basically endless possible combinations of styles and electronic attributes in addition tons of charStyles wouldn't be very convenient).
i think about a gui solution or a two stage process - first read out all used styles then allocate the charstyles.
i will post the solution here.
if it's ok for you i will use your function in my script for the electronic text attributes!
Go ahead. It's there for everyone to take it apart and find smarter ways, or to use it as is. Just don't sell it.
With font styles you mean, differences applied with different fonts? (E.g., helvetica words in otherwise times?) If you know beforehand what fonts there are, you can replace them specifically -- but you'll need to separate between helvetica italic and times italic etc.
You don't know which combinations occur in the document until you search for them. That's why only at that point I create the character style -- otherwise you'd have, what, 64 of em? And that's without searching all caps (I hate those) or different languages.
An alternative route is using TextStyleRanges, which returns literally
little difference in anything in the text. Problem is, it returns way too much! And it's way, way slower than just searching-and-replacing.
Huh -- I enabled a 'Strikeout' loop but forgot to include it in the search function. Corrected.
I could add one more loop for All Capitals, but is that really necessary? (Votes, please.) I could add even more attributes to look for, but remember, each
to search for, will
the running time -- even if it doesn't find anything.
I think All Caps is important because it is not good for people to type things in capital letters. When that text is referenced in a TOC, there is no way to have it in lowercase without highlighting and using 'change case'. But then if the TOC is generated again, this change is lost. I encourage people to use All Caps instead of typing in caps to avoid this issue.
Great script. Thanks.
Fair enough -- I added All Caps.
The nested looping could be redone in a somewhat smarter way, skipping attributes if not wanted, so you'd have a choice of what to include. I'll think some more about that.
I've been trying to include "all caps" on your script but I'm doing something wrong... I've done the following: everytime that "smallcaps" appeared on your script, I've duplicated it and changed to allcaps. I beleive that I have to change something on the first part of your script (the one with the letters and numbers):
for (b=0; b<2; b++)
for (i=0; i<2; i++)
for (s=0; s<2; s++)
for (u=0; u<2; u++)
// Don't process strikeout
for (k=0; k<1; k++)
for (c=0; c<2; c++)
myProgressPanel.myProgressBar.value = 32*b+16*i+8*s+4*u+2*k+c;
findAttr (b, i, s, false, u, /*k*/false, c, "");
findAttr (b, i, false, s, u, /*k*/false, c, "");
Would someone please show me the way? I really don't know anything about scripting yet...
On the previous post, you say that you've added all caps... I beleive it was on a previous version, right?
Thanks a lot!
Now that you mention it, I'm pretty sure I remember someone else asking for an All Caps attribute -- and me replying. Just can't find that version anymore ... I also posted a new & improved version, but that must have been after that All Caps hack.
No worries, though -- I added it (again!) and updated the "preptext.jsx" on my site.
It's not really a big change, but it's tricky: the small caps attribute has the same position in the Character Formatting as the All Caps attribute, and you can't search for both at a time. I'm using that, not by "toggling" the small caps attribute on and off (as with Underline and a few other attributes), but by making it loop from 0 to 2 -- "0" is 'no change', '1' is "Small Caps", '2' is "All Caps". That's in the big loop thing. The other change is in the search-and-replace function:
if (small_all_caps == 1) app.findTextPreferences.capitalization = Capitalization.SMALL_CAPS; if (small_all_caps == 2) app.findTextPreferences.capitalization = Capitalization.ALL_CAPS;-- when small_all_caps is 0, the capitalization field is not used... and added some more code to synthesize a name for the new style: "Caps" (search for "small_all_caps" in the script).Hope I got everything right this time ...
Thanks a lot!!!! You are the best (by the way, I'm the "sadeadu" user - I've messed up with my adobe id somehow).