Highlighted

how to find last paragraph through scripting in js

Community Beginner ,
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

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

With the textframe selected, run the following

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

 

-Manan

Topics

Scripting

Views

295

Likes

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

how to find last paragraph through scripting in js

Community Beginner ,
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

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

With the textframe selected, run the following

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

 

-Manan

Topics

Scripting

Views

296

Likes

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

Copy link to clipboard

Copied

With the textframe selected, run the following

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

 

-Manan

Likes

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
Reply
Loading...
Community Beginner ,
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.

Likes

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
Reply
Loading...
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
Community Beginner ,
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

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jun 01, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...