Converting a pageItem to Interactive Element using a script

New Here ,
Nov 04, 2020

Copy link to clipboard

Copied

Hi,

 

Can you pls tell me how to convert a pageItem into an interactive element (listBox, comboBox, textBox, SignatureBox, etc) using a script? I'm looking for a way to do that NOT by invoking a menu. Also notice that for interactive elements with states there is a command to add pageItems into each state. For the stateless interactive elements how can we do the same?

 

e.g. In a inDesign document we have a rectangle (with a pisture in it) and a polygon grouped together. How can we convert that group to a listBox (NOT by invoking a menu). Converting them we want these pageItems to keep the same ids (group, rectangle, polygon).

 

Regards,

Jim

TOPICS
How to, Scripting

Views

103

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Adobe Community Professional , Nov 04, 2020
Laubender Adobe Community Professional , Nov 04, 2020
Hi Jim, I fear, you have to use the appropriate menu actions to do what you want. Found no method in the scripting DOM for this use case.   Example that is working:     // First select the first text frame on spread 1 of your active document: var textFrameToConvert = app.documents[0].spreads[0].textFrames[0]; app.select( textFrameToConvert ); // Then check, if the menu action is available: // Menu command "Convert To Text Field": var convertToTextField = app.menuActions.itemByName("$ID/$$$/Comm...

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Nov 04, 2020

Copy link to clipboard

Copied

Hi Jim,

do you want to do all of this with InDesign Server?

If not, why do you want to avoid menu actions that are invoked by scripting?

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Nov 04, 2020

Copy link to clipboard

Copied

Hi Laubender, Thanks for the reply. Code is faster, code is cleaner and probable will return the new object.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Nov 04, 2020

Copy link to clipboard

Copied

Hi Jim,

I fear, you have to use the appropriate menu actions to do what you want.

Found no method in the scripting DOM for this use case.

 

Example that is working:

 

 

// First select the first text frame on spread 1 of your active document:
var textFrameToConvert = app.documents[0].spreads[0].textFrames[0];
app.select( textFrameToConvert );

// Then check, if the menu action is available:
// Menu command "Convert To Text Field":
var convertToTextField = app.menuActions.itemByName("$ID/$$$/Command/TextField");

// If available:
if(convertToTextField.enabled)
{
	convertToTextField.invoke();
};

 

 

That means:

[1] You need a selection of the page item you want to convert.

[2] Because I am using a selection and a menu action the code will not run on InDesign Server.

 

Maybe someone chimes in who has a better solution…

 

EDIT: Changed my code a bit.

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more