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

How to Insert a Rectangle Frame Tool Inside a Text Frame in InDesign

Explorer ,
Nov 14, 2025 Nov 14, 2025

Hi sir
I was trying to insert a rectangle frame tool inside a text frame using this code 

const selectedTextFrame = doc.selection[0];
const page = selectedTextFrame.parentPage;
const rect = page.rectangles.add({
geometricBounds: [0, 0, 100, 100],
});
This code creates the rectangle, but it does not place it inside the text frame
TOPICS
How to
69
Translate
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

correct answers 1 Correct answer

Community Expert , Nov 14, 2025 Nov 14, 2025

it does not place it inside the text frame

 

That's because you place it on the page, not in the frame. You should then move the rectangle into the frame (it's not possible to place a rectangle into a text frame directly). Add this to your script:

 

rect.anchoredObjectSettings.insertAnchoredObject (
  selectedTextFrame.insertionPoints[0],
  AnchorPosition.INLINE_POSITION
)
Translate
Community Expert ,
Nov 14, 2025 Nov 14, 2025
LATEST

it does not place it inside the text frame

 

That's because you place it on the page, not in the frame. You should then move the rectangle into the frame (it's not possible to place a rectangle into a text frame directly). Add this to your script:

 

rect.anchoredObjectSettings.insertAnchoredObject (
  selectedTextFrame.insertionPoints[0],
  AnchorPosition.INLINE_POSITION
)
Translate
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