Skip to main content
nickcombs
Inspiring
July 23, 2024
Answered

Changing page item stacking order

  • July 23, 2024
  • 4 replies
  • 652 views

Hi all, I need a javascript method to replicate the following, as seen in the Photoshop and Illustrator object models:

pageItem.move( relativeObject, ElementPlacement )

 

I feel like I'm missing something obvious, but I've been looking for a while. Surely someone has tried to do this before?

This topic has been closed for replies.
Correct answer brian_p_dts

pageitem.bringToFront() will bring it to the top of layer, sendToBack() at bottom of layer. You can pass another pageitem reference to bring object in front or behind it.

4 replies

rob day
Community Expert
Community Expert
July 24, 2024

Hi @nickcombs , there’s also bringForward() and sendBackward(), which moves the object up or down the z-order.

 

//move the selected object up
app.activeDocument.selection[0].bringForward()
Robert at ID-Tasker
Legend
July 23, 2024

@nickcombs

 

InDesign doesn't offer direct access to the Z-order. 

 

m1b
Community Expert
Community Expert
July 23, 2024

Hi @nickcombs, wow I can't believe I've never noticed this before! You're right that Indesign's PageItem.move doesn't work like Illustrator/Photoshop. It seems to only allow you to move to a new Layer, Page, Spread or Document. Best I could find quickly was to use another layer and shuffle the items back and forth to adjust the order. Not great. Hopefully someone will have a better idea!

- Mark

 

Edit: Thanks @brian_p_dts!

brian_p_dts
Community Expert
Community Expert
July 23, 2024

Do you mean to tell me that ID, PS and AI APIs have practically nothing in common?!?! Perish the thought 😆 

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
July 23, 2024

pageitem.bringToFront() will bring it to the top of layer, sendToBack() at bottom of layer. You can pass another pageitem reference to bring object in front or behind it.

nickcombs
nickcombsAuthor
Inspiring
July 23, 2024

This is perfect. Thank you!