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

[CS4][JS] Accessing skewed text items

Guest
Dec 17, 2008 Dec 17, 2008
The following code snippet successfully finds all the skewed text in a
document and then removes the skew:

//Clear the find/change preferences.
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeTextOptions.caseSensitive = false;
app.findChangeTextOptions.includeFootnotes = false;
app.findChangeTextOptions.includeHiddenLayers = false;
app.findChangeTextOptions.includeLockedLayersForFind = false;
app.findChangeTextOptions.includeLockedStoriesForFind = false;
app.findChangeTextOptions.includeMasterPages = false;
app.findChangeTextOptions.wholeWord = false;
//Search the document for all the skewed text
app.findTextPreferences.skew = 1;
// now remove all skews
app.changeTextPreferences.skew = 0;

However, I want to access each fragment of skewed text rather than
globally change them.

How do I access the collection of skewed text items as the
findTextPreferences does not seem to possess the required properties.

TIA

Doug Neale
TOPICS
Scripting
624
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 ,
Dec 17, 2008 Dec 17, 2008
You say something like this:
>var myFound = app.activeDocument.findText();

which creates an array (myFound) of of all found items. You can process that array as usual, i.e.
>for (i = 0; i < myFound.length; i++)

> // do something with each myFound

Peter
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
Guest
Dec 18, 2008 Dec 18, 2008
Hi Peter,

I tried this on a single page document with some text set in italics:

//Clear the find/change preferences.
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeTextOptions.caseSensitive = false;
app.findChangeTextOptions.includeFootnotes = false;
app.findChangeTextOptions.includeHiddenLayers = false;
app.findChangeTextOptions.includeLockedLayersForFind = false;
app.findChangeTextOptions.includeLockedStoriesForFind = false;
app.findChangeTextOptions.includeMasterPages = false;
app.findChangeTextOptions.wholeWord = false;
//Search the document for all the skewed text
app.findTextPreferences.skew = 1;

var myFound = app.activeDocument.findText();


if (myFound.length==0) {
alert("No skewed text was found");
}
else {
// ok we have some skewed text, now loop through each one
for (i =0; i < myFound.length; i++) {
var myTextObject = myFound;
var myText = myTextObject.Content;
}
}

and it always finishes up with the alert :-(
and debug confirmed that myFound.length was zero.

Should I be doing something else to find italic text?

Regards,

Doug Neale
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 ,
Dec 18, 2008 Dec 18, 2008
Well, you're searching text skewed by 1 degree, so you're not going to find italics. If that's what you're after, do app.findTextPreferences.fonStyle = 'Italic' instead.

Peter
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
Participant ,
Dec 18, 2008 Dec 18, 2008
Italic and Skew are two different things. The skew value for text is an explicit number representing to angle of skew, so finding all skewed text is going to be a tad difficult. You might have to do it by exception, that is, look for a skew of zero and any text you don't find is skewed.

Dave
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
Guest
Dec 18, 2008 Dec 18, 2008
LATEST
Thanks Guys,

That did the trick.

If the skewed text is initially in italics, it is picked up by looking
for all italic text.

If not, then I shall have to work through all the story textStyleRanges
one by one., and if there are tables present, every cell as well.

Regards,

Doug Neale
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