Highlighted

fetching last paragraph problem

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.

Topics

Scripting

Views

129

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

fetching last paragraph problem

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.

Topics

Scripting

Views

130

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

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

 

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