Known Participant
October 9, 2022
Answered
Anchored images disappear after script replaces text
- October 9, 2022
- 4 replies
- 2531 views
I have a script that changes the encoding of an Indic document to Unicode by iterating over textStyleRanges. The encoding change is based on existing well-tested JS code and works great except that the anchors text-colors all move or disappear on conversion.
function ascii2unicode(text){ var words = text.split(' '); // To stote converted words var op_words = []; // Process and append to main array words.forEach(function(word, k, arr){ op_words.push('mwe-text'); }); // Return converted line return op_words.join(' '); } var doc = app.activeDocument; var stories = doc.stories; var textStyleRanges = stories.everyItem().textStyleRanges.everyItem().getElements(); for (var i = textStyleRanges.length-1; i >= 0; i--) { var myText = textStyleRanges[i]; if (myText.appliedFont.fontFamily.toLowerCase().indexOf('nudi') == 0) { var converted = ascii2unicode(myText.contents); if (myText.contents != converted) { myText.contents = ""; myText.appliedFont = app.fonts.item("Tunga"); myText.contents = converted; myText.composer="Adobe World-Ready Paragraph Composer"; } } }
