Highlighted

Set selected text to superscript

New Here ,
Apr 29, 2020

Copy link to clipboard

Copied

Dear all,

I want to superscript the selected text from sentences by using script.

can anyone help me to how to write this with example.

Thanks.

Adobe Community Professional
Correct answer by Sunil Yadav | Adobe Community Professional

Understand the concept here.

 

As Manan mentioned that you are adding new document and new text frame and you are adding contents to it.

To make "Kenmore" bold you need to apply bold character style, for this there may be several approach.

I can see that here "Kenmore" is being first word of the text frame so I can make it bold from word appaoch like this :

frame.words[0].applyCharacterStyle(bold);

You may have different appraoch as well.

 

Best

Sunil

TOPICS
Scripting

Views

230

Likes

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

Set selected text to superscript

New Here ,
Apr 29, 2020

Copy link to clipboard

Copied

Dear all,

I want to superscript the selected text from sentences by using script.

can anyone help me to how to write this with example.

Thanks.

Adobe Community Professional
Correct answer by Sunil Yadav | Adobe Community Professional

Understand the concept here.

 

As Manan mentioned that you are adding new document and new text frame and you are adding contents to it.

To make "Kenmore" bold you need to apply bold character style, for this there may be several approach.

I can see that here "Kenmore" is being first word of the text frame so I can make it bold from word appaoch like this :

frame.words[0].applyCharacterStyle(bold);

You may have different appraoch as well.

 

Best

Sunil

TOPICS
Scripting

Views

231

Likes

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
Apr 29, 2020 0
Adobe Community Professional ,
Apr 30, 2020

Copy link to clipboard

Copied

Select the text and run the following code snippet

app.selection[0].position = Position.SUPERSCRIPT

 

-Manan

Likes

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
Reply
Loading...
Apr 30, 2020 1
New Here ,
Apr 30, 2020

Copy link to clipboard

Copied

Could you please explain for this script, Please do superscript for "Kenmore" 

 

 

var doc = app.documents.add();

var frame = doc.pages[0].textFrames.add({
geometricBounds: [6, 6, 15, 18]
});

var bold = doc.characterStyles.add({ name: "Bold", fontStyle: "Bold" });


frame.parentStory.appliedFont = "Helvetica LT std" //Change with the name of the font you want
frame.parentStory.pointSize = "8" // change font size if you want


frame.insertionPoints.lastItem().contents = "Kenmore\n";
frame.insertionPoints.lastItem().contents = "Customer Care Hotline\n";
frame.insertionPoints.lastItem().contents = "To schedule in-home repair service\n";
frame.insertionPoints.lastItem().contents = "or order replacement parts\n";

frame.insertionPoints.lastItem().applyCharacterStyle(bold);
frame.insertionPoints.lastItem().contents = "1-844-553-6667";

 

 

 

 

 

 

 

 

 

 

Likes

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
Reply
Loading...
Apr 30, 2020 0
Adobe Community Professional ,
May 01, 2020

Copy link to clipboard

Copied

Understand the concept here.

 

As Manan mentioned that you are adding new document and new text frame and you are adding contents to it.

To make "Kenmore" bold you need to apply bold character style, for this there may be several approach.

I can see that here "Kenmore" is being first word of the text frame so I can make it bold from word appaoch like this :

frame.words[0].applyCharacterStyle(bold);

You may have different appraoch as well.

 

Best

Sunil

Likes

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
Reply
Loading...
May 01, 2020 0
Adobe Community Professional ,
Apr 30, 2020

Copy link to clipboard

Copied

I would be better you study the code by self and try to understand it and ask things that are not clear to you. Asking to explain a script you get from somewhere does not make sense. Putting in effort helps. Your script is creating a document, adding a text frame and then content to the frame.

 

As i mentioned in order to set the superscript you need to set the position property of the text, the same property exists on insertionPoint as well. Insertionpoint could be thought of as a cursor point, so for your question of setting Kenmore to superscript. You need to set the position to superscript before you add the text Kenmore and set the position to normal after this text. I will leave writing the code to you now, try it i have explained everything. Have a look at the following as well

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#InsertionPoint.html

 

-Manan

 

Likes

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
Reply
Loading...
Apr 30, 2020 1