Copy link to clipboard
Copied
Can somebody tell me what is the code to return the paragraph style for the current cursor position.
Also I can I apply something to the the current paragragh not useing pragraph styles.
For example what would be the code for "Make current paragraph text Red".
Help would be much appreciated as one can see from the questions I am a complete novice in scripting.
if (app.documents.length > 0 && app.selection.length === 1 && app.selection[0].hasOwnProperty("baseline")) {
// return the paragraph style for the current cursor position
alert("Paragraph style: " + app.selection[0].appliedParagraphStyle.name);
// Make current paragraph text Red (the 1st paragraph in the selection)
app.selection[0].paragraphs[0].fillColor = "C=15 M=100 Y=100 K=0";
}
Copy link to clipboard
Copied
Hi,
Do you mean something like this:
var document = app.documents.add();
var textFrame = document.textFrames.add();
textFrame.geometricBounds = [30, 30, 200, 300];
textFrame.contents = "Hello InDesign World\rSecond Paragraph\rThird Paragraph";
textFrame.recompose();
if(textFrame.paragraphs.length > 2)
{
// Get the second paragraph
var paragraph = textFrame.paragraphs[1];
var redColor = document.colors.add({colorValue: [255, 0, 0], space: ColorSpace.RGB});
// Make second paragraph bigger and red
paragraph.pointSize = 24;
paragraph.fillColor = redColor;
}
Copy link to clipboard
Copied
if (app.documents.length > 0 && app.selection.length === 1 && app.selection[0].hasOwnProperty("baseline")) {
// return the paragraph style for the current cursor position
alert("Paragraph style: " + app.selection[0].appliedParagraphStyle.name);
// Make current paragraph text Red (the 1st paragraph in the selection)
app.selection[0].paragraphs[0].fillColor = "C=15 M=100 Y=100 K=0";
}
Copy link to clipboard
Copied
Thanks a lot 100% exactly what I wanted.