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

How to define a round corner textframe in Javascript

Community Beginner ,
Mar 22, 2012 Mar 22, 2012

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.

TOPICS
Scripting

Views

961

Translate

Translate

Report

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 Beginner , Mar 23, 2012 Mar 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.

Votes

Translate

Translate
Community Expert ,
Mar 22, 2012 Mar 22, 2012

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

Votes

Translate

Translate

Report

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
Community Beginner ,
Mar 22, 2012 Mar 22, 2012

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 !

Votes

Translate

Translate

Report

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
Community Beginner ,
Mar 23, 2012 Mar 23, 2012

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.

Votes

Translate

Translate

Report

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
Explorer ,
Mar 28, 2023 Mar 28, 2023

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

 

Votes

Translate

Translate

Report

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
Community Expert ,
Mar 28, 2023 Mar 28, 2023

Copy link to clipboard

Copied

LATEST

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. 

 

ID-Tasker - most powerful tool ever created for InDesign

Votes

Translate

Translate

Report

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