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

Hi character.remove() is crashing the Indesign server.

New Here ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

    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.
 
TOPICS
Bug , Scripting

Views

301
Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

I've seen this a few times at the level of story, maybe the underltying problem is the same as with character. Anyway, try

 

foundItems[i].contents = ''

 

 

Votes

Translate

Report

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
New Here ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

But this wont cause any issue right. as we are just assigning '' empty character and not removing the character itself.

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

character.remove() and character.contents = '' are equivalent. They have the same effect. It won't cause any problems. Just try it.

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

@adarsh_0848

 

Why do you have to iterate through all results - instead of doing Find&Change?

 

Votes

Translate

Report

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
New Here ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

I dont want to change all the found Charcters, In my Codebase I have created custom character style and applied to Characters for processing some other functionality (which I have not shared here). But Conclusion is I want to remove characters with perticular character style . if (foundItems[i].appliedCharacterStyle == markerStyle)

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

But you're looking for a specific marker: 

 

app.findGrepPreferences.findWhat = BOUNDARY_MARKER; 

 

So if you'll combine this marker WITH specific CharStyle - you can use Find&Change to remove ONLY instances where this specific marker has this specific CharStyle applied. 

 

Votes

Translate

Report

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
New Here ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

Something like this 

  app.findGrepPreferences = NothingEnum.NOTHING;
            app.changeGrepPreferences = NothingEnum.NOTHING;

            // Find all hair spaces with our specific style
            app.findGrepPreferences.findWhat = BOUNDARY_MARKER;
            app.findGrepPreferences.appliedCharacterStyle = markerStyle;

            // Remove them
            var foundItems = document.findGrep();?
.But  app.findGrepPreferences.appliedCharacterStyle  is also crashing the server. 

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

Yes. 

 

If it crashes - then your file might be corrupted - or you've a problem with fonts? 

 

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

And you don't have to store results - just changeGrep() ;

 

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

 

app.findGrepPreferences.findWhat = BOUNDARY_MARKER;
app.findGrepPreferences.appliedCharacterStyle = markerStyle; 

 

Votes

Translate

Report

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
New Here ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

Even that being the case I have set up try catch, its not going into catch, Server just stops here

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

quote

Even that being the case I have set up try catch, its not going into catch, Server just stops here


By @adarsh_0848

 

Have you tried on the desktop version? 

 

Votes

Translate

Report

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
New Here ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

In desktop there is not issue at all. I'm facing issue in Indesign Server with same document.

 

Votes

Translate

Report

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 ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

quote

In desktop there is not issue at all. I'm facing issue in Indesign Server with same document.


By @adarsh_0848

 

Are you sure you've EXACTLY the same fonts? 

 

Votes

Translate

Report

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
New Here ,
Mar 05, 2025 Mar 05, 2025

Copy link to clipboard

Copied

Yes I'm sure. I'm using the same document in both InDesign desktop and InDesign server. 

Votes

Translate

Report

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 ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

quote

Yes I'm sure. I'm using the same document in both InDesign desktop and InDesign server. 


By @adarsh_0848

 

But I'm asking about the "environment", not documents. 

 

Fonts are not part of the Document. 

 

If you'll have conflicting / duplicated or corrupted fonts on the server - and not on the desktop... 

 

Try IDMLing on your INDD file anyway - export as IDML, open, save with a new name - do not overwrite your original file - maybe Server is more "sensitive"?? 

 

Votes

Translate

Report

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
New Here ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

I'm not sure about fonts(where are they stored), I can see font present in InDesign server aswell, I am using Adobe ExtendScript Toolkit CC to debug InDesign server process of executing scripts. I can see paragraph style and fonts applied to the character which I want to remove.
PS: I have created IDML, what should I do next, try and run scripts on that in InDesign server?

 

Votes

Translate

Report

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 ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

@adarsh_0848

 

Yes, use new INDD file after IDMLing.

 

Votes

Translate

Report

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
New Here ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

Thank you@Robert at ID-Tasker, this works, so the thing is Fonts, Linked Graphics etc (image below)

adarsh_0848_0-1741266435231.png

are part of package.

, But the

  1. Paragraph Styles & Character Styles
  2. Object Styles
  3. Table & Cell Styles
  4. Master Pages (Parent Pages)
  5. Layers & Layer Structure
  6. Text Content
  7. Vector Shapes & Graphics
  8. Swatches & Color Data
  9. Hyperlinks & Cross-references
  10. TOC & Index Entries
  11. Interactive Elements
  12. Metadata
  13. Guides & Grids
  14. Scripts & Variables
  15. Story Editor & Overset Text
  16. XML Structure & Tags etc
    are embedded into the .indd right? 

Votes

Translate

Report

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 ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

So IDMLing worked - and your original INDD file was corrupted? 

 

7 - depends if they are made of native objects - Rectangle, line, oval, TF, polygon - or are linked external files. You can also embed external files.

 

14 - scripts - no. 

 

Votes

Translate

Report

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
New Here ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

LATEST

I still don't know what was causing the as I am creating a custom character style with default font and font size as 0.1 and processing(more than 200+ lines of code, this doesnt manipulate the font or the character style) it. Once the processing is done I am removing the characters and the character style.

But foundItems[0].remove() wasnt crashing for all the characters for few it was.

Votes

Translate

Report

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 ,
Mar 06, 2025 Mar 06, 2025

Copy link to clipboard

Copied

6 - not sure - never checked - you can link external doc / excel file - but contents is directly available for modification - although, everything might will go out of whack when the original linked file gets updated...

 

Votes

Translate

Report

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