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

how to find last paragraph through scripting in js

Community Beginner ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

can u help me in code of scripting in js to find the last paragraph of text story in a text frame

TOPICS
Scripting

Views

636

Translate

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

Community Expert , Jun 01, 2020 Jun 01, 2020

With the textframe selected, run the following

app.selection[0].parentStory.paragraphs[-1]

 

-Manan

Votes

Translate

Translate
Community Expert ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

With the textframe selected, run the following

app.selection[0].parentStory.paragraphs[-1]

 

-Manan

Votes

Translate

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
Community Beginner ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

var myDocument=app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds=["6p","6p","24p","24p"];
myTextFrame.contents="She is an essence of truthfulness, love, and sincerity. Another reason is that she showers her family with her blessing and live. Furthermore, she gives us everything but never demand anything in return. The way she cares for everyone in the family inspires me to the same in my future\n Also, her love is not just for the family she treats every stranger and animals the same way she did to me. Due to, this she is very kind and sensible towards the environment and animals.";
sel = myTextFrame;
var cat=myTextFrame.parentStory.paragraphs[-1];
alert(cat.contents);
alert("paragraph selected");
this is my code but its giving the entire text.
can u suggest me possible corrections.

Votes

Translate

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
Community Expert ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

In your contents string change \n to \r. \n creates a soft return and hence a new paragraph is not created that is the reason you get the whole content of the paragraph. \r creates two paragraphs

 

P.S. :- Don't post new topics for the same question, it will not get you faster answers. Maintain the decorum of the forum

-Manan

Votes

Translate

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
Community Beginner ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

thanks a lot for your help.can you suggest me from where one can read and gain knowledge about scripting

Votes

Translate

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
Community Expert ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

LATEST

See a related post that lists resources on how to learn scripting for InDesign

https://community.adobe.com/t5/indesign/what-are-some-good-resources-for-learning-extendscript/td-p/...

 

-Manan

Votes

Translate

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