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

InDesign Crash While executing this script

Explorer ,
Apr 03, 2023 Apr 03, 2023

Copy link to clipboard

Copied

Hi,

 

I have used the script in the SDK source. While executing this script the InDesign Application gets crashed. Please guide me on this.

 

 

InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));
InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
PMString scriptCode;	
	scriptCode.Append("function IterateDocument(){");
	scriptCode.Append("var doc = app.activeDocument;");
	scriptCode.Append("doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.POINTS;");
	scriptCode.Append("doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;");
	scriptCode.Append("for (var i = 0; i < doc.pages.length; i++)");
	scriptCode.Append("{");
	scriptCode.Append("var page = doc.pages[i];");
	scriptCode.Append("var pageHeight = page.bounds[2] - page.bounds[0];");
	scriptCode.Append("for (var j = 0; j < page.textFrames.length; j++) {");
	scriptCode.Append("var frame = page.textFrames[j];");
	scriptCode.Append("if (frame.overflows  == true && frame && frame.associatedXMLElement && frame.associatedXMLElement.markupTag && frame.associatedXMLElement.markupTag.name == 'products')");
	scriptCode.Append("{");
	scriptCode.Append("for(var k = frame.tables.length-1; k >= 0; k--) {");
	scriptCode.Append("var table = frame.tables[k];");
	scriptCode.Append("if (pageHeight < table.height) {");
	scriptCode.Append("AddColumnToTable(frame, i, table);");
	scriptCode.Append("}");
	scriptCode.Append("}");
	scriptCode.Append("}");
	scriptCode.Append("}");
	scriptCode.Append("}");
	scriptCode.Append("app.activeDocument.documentPreferences.facingPages = true;");	
	scriptCode.Append("}");
	scriptCode.Append("function AddColumnToTable (mySel,addPageLocation, originalTable)");
	scriptCode.Append("{");
	scriptCode.Append("app.activeDocument.documentPreferences.facingPages = false;");
	scriptCode.Append("var gb = mySel.geometricBounds;");
	scriptCode.Append("gb[2] = gb[0] + originalTable.height/2;");
	scriptCode.Append("gb= [95.891, 37.5, 640, 540];");
	scriptCode.Append("mySel.geometricBounds = gb;");
	scriptCode.Append("var newPage = app.activeDocument.pages.add(LocationOptions.AFTER, app.activeDocument.pages[addPageLocation]);");
	scriptCode.Append("var textframe = app.activeDocument.pages[addPageLocation+1].textFrames.add({geometricBounds:[95.891, 37.5, 640, 540]});");
	scriptCode.Append("mySel.nextTextFrame = textframe;");
	scriptCode.Append("textframe.fit(FitOptions.frameToContent);");
	scriptCode.Append("if(textframe.overflows  == true){");
	scriptCode.Append("addPageLocation = addPageLocation +1;");
	scriptCode.Append("AddColumnToTable (textframe,addPageLocation,originalTable);");
	scriptCode.Append("}");
	scriptCode.Append("}");

	PMString engineName("myengine");
	int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, scriptCode);
	Utils<IScriptArgs>()->Clear();

 

The issue is from the line 

 

scriptCode.Append("app.activeDocument.documentPreferences.facingPages = true;");

 

  

TOPICS
Bug , How to , SDK

Views

170

Translate

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
Adobe Employee ,
Apr 05, 2023 Apr 05, 2023

Copy link to clipboard

Copied

Hi @Barathi,

 

Thank you for reaching out. Would you mind telling us if InDesign is crashing while using this script only? Please share the version of InDesign and the details of your operating system so that we can investigate on the issue.

 

Please generate logs from the log collector tool and upload them to a shared location such as CC or Dropbox and share the URL with me over a private message.

 

We will try our best to help.

 

Thanks,

Harshika

Votes

Translate

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 ,
Apr 05, 2023 Apr 05, 2023

Copy link to clipboard

Copied

LATEST

Hi @Barathi,

I would suggest that you isolate all the script code in a jsx file and then test it. If you still find issues then post the jsx code and sample document to test it.

-Manan

Votes

Translate

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