Copy link to clipboard
Copied
Hi,
I'm trying to create my first script (using javascript)... The idea is to increase (or decrease) space after a paragraph (0.5 mm). I can't find anywhere how can I get the space after value of a selected paragraph... Could someone please help me?
I'm brazilian... Sorry about my bad english!
Thanks.
Hi,
try this code:
var allPara = app.documents[0].stories.everyItem().paragraphs;
for(var p = 0; p < allPara.length; p++){
// for decreasing----
if(allPara
.spaceAfter > 0.5){
allPara
.spaceAfter = allPara
.spaceAfter - 0.5;
}
// for increasing no need to check any condition----
allPara
.spaceAfter = allPara
.spaceAfter + 0.5;
}
Depending on your need you can change the idea of getting paragraphs on line 01.
If you want to decrease you should check if space after is already mo
...Copy link to clipboard
Copied
Hi.
try this code
var para = app.selection[0].paragraphs;
try {
para[0].spaceAfter -= 0.5; // or += 0.5
}
catch(e){alert(e);} // space after and space before must >= 0
and, you can get other properties with this code
$.writeln(para[0].properties.toSource().replace(/,/g,",\n"));
thankyou,
mg
Copy link to clipboard
Copied
For those interested, cause this came in handy for me.
Here is incremental space after, looped and without the alert as per a normal indesign incremental shortcut function.
Thanks.
//without alert
var para = app.selection[0].paragraphs;
for(var n=0;n<para.length;n++) {
try {
para
.spaceAfter += 1/12; }
catch(e){}; // space after and space before must >= 0
}
Copy link to clipboard
Copied
Hi,
try this code:
var allPara = app.documents[0].stories.everyItem().paragraphs;
for(var p = 0; p < allPara.length; p++){
// for decreasing----
if(allPara
.spaceAfter > 0.5){
allPara
.spaceAfter = allPara
.spaceAfter - 0.5;
}
// for increasing no need to check any condition----
allPara
.spaceAfter = allPara
.spaceAfter + 0.5;
}
Depending on your need you can change the idea of getting paragraphs on line 01.
If you want to decrease you should check if space after is already more than 0.5 otherwise you'll get error.
And for increasing space after no need to check any.
Best
Sunil