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

Set selected text to superscript

New Here ,
Apr 29, 2020 Apr 29, 2020

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.

TOPICS
Scripting
685
Translate
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

Advocate , May 01, 2020 May 01, 2020

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

Translate
Community Expert ,
Apr 30, 2020 Apr 30, 2020

Select the text and run the following code snippet

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

 

-Manan

Translate
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
New Here ,
Apr 30, 2020 Apr 30, 2020

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";

 

 

 

 

 

 

 

 

 

 

Translate
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
Advocate ,
May 01, 2020 May 01, 2020
LATEST

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

Translate
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 ,
Apr 30, 2020 Apr 30, 2020

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

 

Translate
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