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

Getting and setting paragraphs space after

New Here ,
Mar 11, 2012 Mar 11, 2012

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.

TOPICS
Scripting

Views

1.2K
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
community guidelines

correct answers 1 Correct answer

Advocate , Aug 07, 2019 Aug 07, 2019

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

...

Votes

Translate
Contributor ,
Mar 11, 2012 Mar 11, 2012

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

Votes

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
community guidelines
Guest
Aug 07, 2019 Aug 07, 2019

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 

}

Votes

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
community guidelines
Advocate ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines