Copy link to clipboard
Copied
I have a script that loops over textStyleRanges and replaces non-Unicode contents by Unicode.
var stories = app.activeDocument.stories.everyItem().getElements();
for (var i = 0; i < stories.length; i++) {
var textStyleRanges = stories.textStyleRanges.everyItem().getElements();
for (var j = textStyleRanges.length-1; j >= 0; j--) {
var myText = textStyleRanges
if (matches(myText.appliedFont.fontFamily)) {
var converted = convert_to_unicode(myText.contents);
if (converted != undefined) {
myText.contents = converted;
myText.appliedFont = app.fonts.item("Utsaah");
myText.composer = "Adobe World-Ready Paragraph Composer";
}
}
}
}
While I am not touching the text colors, they seem to have moved to the next paragraph, in at least two cases shown above. What could be happening?
Thanks,
Himanshu
Copy link to clipboard
Copied
Hi Himanshu,
I'm not clear at all why this happens.
Only one suggestion:
Duplicate a given range to a new text frame, do the conversion there.
Give every duplicate its own text frame.
Do not touch the original in that loop.
Assemble all converted text after you made all the conversions.
Regards,
Uwe
Copy link to clipboard
Copied
Hi Uwe,
Thanks for your reply. While I haven't tried what you suggested, here is a screenshot of the exported idml file, which shows that some ParagraphStyles are lost and their characterStyles merged with previous. Does this help?
Thanks,
Himanshu
Copy link to clipboard
Copied
HI,
Could you share a sample document using a file sharing service, so that we can take a look at the before and after to see if we can spot the problem?
Regards
Malcolm
Copy link to clipboard
Copied
Thanks for offering to check this. Here is the link: ID-Scripting-Forum - Google Drive