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.
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
Copy link to clipboard
Copied
Select the text and run the following code snippet
app.selection[0].position = Position.SUPERSCRIPT
-Manan
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";
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
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now