Skip to main content
Known Participant
April 10, 2017
Question

How can i cut rectangle into the textFrame script?

  • April 10, 2017
  • 4 replies
  • 896 views

How can i cut rectangle into the textFrame script? Please help me

This topic has been closed for replies.

4 replies

Community Expert
April 11, 2017

Hi Ahmet,

if your version of InDesign is CS5.5 or above you can use the method insertAnchoredObject() of the anchoredObjectSettings of your rectangle. The method requires two arguments: storyOffset and anchoredPosition . storyOffset is an insertionPoint, one in your textFrame you like the rectangle to be anchored with, anchoredPosition is the kind of anchoring you like to do: inline, above line or anchored expressed with enumerators.

Have two objects on page 1 of your document.

A rectangle and a text frame.

var rectangle = app.documents[0].rectangles[0];

var textFrame = app.documents[0].textFrames[0];

// Anchor the rectangle inline  at the first insertion point of the text frame:

rectangle.anchoredObjectSettings.insertAnchoredObject( textFrame.insertionPoints[0] , AnchorPosition.INLINE_POSITION );

See also DOM documentation here:

Indesign JavaScript Help

Adobe InDesign CS6 (8.0) Object Model JS: AnchoredObjectSetting

Regards,
Uwe

ibrahimd67324582
Known Participant
April 10, 2017

I understood what he is talking about. He wants to cut unanchored text frame or unanchored object into the text frame.

Known Participant
April 10, 2017

Before:

After:

Anantha Prabu G
Legend
April 10, 2017

Hi,

Try this code!!!

    

var myDoc = app.activeDocument;

var myTextFrame = myDoc.textFrames.everyItem().getElements();

var ins=app.activeDocument.textFrames.item(0).insertionPoints.item(2);

var Rec = ins.rectangles.add();

Rec.geometricBounds = ["4p","3p", "10p", "10p"]

Thanks,

Prabu G

Design smarter, faster, and bolder with InDesign scripting.
Jongware
Community Expert
Community Expert
April 10, 2017

This needs more words. And perhaps a few images: do it by hand, and show the difference before/after.