Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 !
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks you!! Just the code I needed and works PERFECTLY. I applied it in the context of a rectangle object in the snipped below, where I had a variable called roundedCorner which was = 12 inches in my case.
// Create the Finished Size rectangle
var finishedRect = graphicTemplate.pages.item(0).rectangles.add({
geometricBounds: [(graphicTemplate.documentPreferences.pageHeight - finishedHeight+finishedSizeStroke) / 2, (graphicTemplate.documentPreferences.pageWidth - finishedWidth+finishedSizeStroke) / 2, (graphicTemplate.documentPreferences.pageHeight + finishedHeight-finishedSizeStroke) / 2, (graphicTemplate.documentPreferences.pageWidth + finishedWidth-finishedSizeStroke) / 2],
strokeWeight: finishedSizeStroke,
strokeColor: "Black",
strokeType: "Dashed (4 and 4)",
fillColor: "None",
transparencySettings: { blendingSettings: { opacity: 100 } },
topLeftCornerOption: CornerOptions.ROUNDED_CORNER,
topLeftCornerRadius: roundedCorner,
topRightCornerOption: CornerOptions.ROUNDED_CORNER,
topRightCornerRadius: roundedCorner,
strokeAlignment: StrokeAlignment.CENTER_ALIGNMENT
Copy link to clipboard
Copied
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.