Question
Hi character.remove() is crashing the Indesign server.
function removeBoundaryMarkers(document) {
try {
logMsg(logFile, "Fetching marker style: " + MARKER_STYLE_NAME);
// Find our specific marker style
var markerStyle = document.characterStyles.itemByName(MARKER_STYLE_NAME);
if (!markerStyle.isValid) {
return;
}
logMsg(logFile, "Resetting findGrepPreferences and changeGrepPreferences");
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
// Find all hair spaces
logMsg(logFile, "Setting findGrepPreferences.findWhat");
app.findGrepPreferences.findWhat = BOUNDARY_MARKER;
// Remove them if they have the specific style
logMsg(logFile, "Executing findGrep");
var foundItems = document.findGrep();
logMsg(logFile, "Found " + foundItems.length + " items to check and remove");
for (var i = foundItems.length - 1; i >= 0; i--) {
if (foundItems[i].appliedCharacterStyle == markerStyle) {
logMsg(logFile, "Removing marker : "+i);
if (foundItems[i].contents.length > 0) {
foundItems[i].remove();
}
}
}
// Clean up the style
logMsg(logFile, "Removing marker style");
markerStyle.remove();
} catch (e) {
logMsg(logFile, "Error removing boundary markers: " + e.message);
}
}
}
This funtion just gets the Hair Space content and compares with specific chracter style, and removes the character. But, the issue im facing is foundItems, is gettign around 130 characters, able to remove from 130 till 91 but at 90th character, when foundItems[i].remove(); InDesign server crashes. What could be the issue.
This funtion just gets the Hair Space content and compares with specific chracter style, and removes the character. But, the issue im facing is foundItems, is gettign around 130 characters, able to remove from 130 till 91 but at 90th character, when foundItems[i].remove(); InDesign server crashes. What could be the issue.
