Skip to main content
Inspiring
March 22, 2012
Answered

How to define a round corner textframe in Javascript

  • March 22, 2012
  • 2 replies
  • 1745 views

Hi,

For my automatic layout I would like to create some rounded corner textframes by using javascript but... I don't know how to do that. I put an eye on CornerEffects.jsx hoping to copy a part of the code, but it's not so clear for me.

Do you have any clue to help me doing that ?

Thank you.

This topic has been closed for replies.
Correct answer Boitaumail

Hi,

To help the others after me. Here is a piece of code which work for me (CS5) :

myTextFrame.bottomLeftCornerOption = CornerOptions.ROUNDED_CORNER;

myTextFrame.bottomLeftCornerRadius = 5;

Thank you Laubender.

2 replies

Robert at ID-Tasker
Legend
March 28, 2023

Why are you trying to make you life so hard? 😉 

 

Use Object Styles - when you need to reformat those objects - you won't have to go through them all again - just a quick edit of the Object Style - that can be even done by the end user without the need to bother you to make changes in the script 😉 

 

And if you have a need for a different corners for different types of objects - you can just apply a different Object Style. 

 

Community Expert
March 22, 2012

That will depend on the version of InDesign you are using.

There are three (or more) distinct ways to apply rounded corners:

1.a You could add a text frame and define cornerOption and cornerRadius (InDesign CS4)

1.b You could add a text frame and define bottomLeftCornerOption, bottomLeftCornerRadius etc. (InDesign CS5 and CS5.5)

2. You could use the method convertShape() on a rectangular text frame.

3. The geometric way involving circles (ovals) and rectangles and adding them to one single path.

4. Or build one path with rounded corners from scratch and change its contentType to ContentType.TEXT_TYPE

See Jongware's reference for the DOM objects and methods:
http://www.jongware.com/idjshelp.html

Uwe

Inspiring
March 22, 2012

Thank you very much,

Actually I'm using InDesign CS5.

I will try the 1.b solution and come back to confirm that everything is fine !

BoitaumailAuthorCorrect answer
Inspiring
March 23, 2012

Hi,

To help the others after me. Here is a piece of code which work for me (CS5) :

myTextFrame.bottomLeftCornerOption = CornerOptions.ROUNDED_CORNER;

myTextFrame.bottomLeftCornerRadius = 5;

Thank you Laubender.