Highlighted

Adding a space in the end of the table cell with extendscript

Community Beginner ,
Jan 16, 2019

Copy link to clipboard

Copied

Does anybody know how can I add a space in the end of the table cell with extendscript.

I have object of the cell and want to get the text/string and add a space in the end.

TOPICS
Scripting

Views

557

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

Adding a space in the end of the table cell with extendscript

Community Beginner ,
Jan 16, 2019

Copy link to clipboard

Copied

Does anybody know how can I add a space in the end of the table cell with extendscript.

I have object of the cell and want to get the text/string and add a space in the end.

TOPICS
Scripting

Views

558

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
Jan 16, 2019 0
Advocate ,
Jan 16, 2019

Copy link to clipboard

Copied

The Cell object has a FirstPgf. If there may be more paragraphs in the cell, you need to cycle through the list of Pgf objects to get to the last one. Then set a TextLoc object to point to the end of that Pgf and use that TextLoc in the document's AddText method. Here is some untested code:

var oDoc = app.ActiveDoc;

var oPgf = oCell.FirstPgf;

while( oPgf.NextPgfInCell.ObjectValid( ) )

{

     oPgf = oPgf.NextPgfInCell;

}

var oTLoc = new TextLoc( oPgf, Constants.FV_OBJ_END_OFFSET );

oDoc.AddText( oTLoc, " "  );

Hope this works. Check the Scriping Guide if not - there might be typos in the property names.

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...
Jan 16, 2019 2
Adobe Community Professional ,
Jan 16, 2019

Copy link to clipboard

Copied

Assuming cell as your cell object and doc as your document object:

var textLoc;

textLoc = new TextLoc (cell, Constants.FV_OBJ_END_OFFSET - 1);

doc.AddText (textLoc, " ");

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...
Jan 16, 2019 2
Community Beginner ,
Jan 16, 2019

Copy link to clipboard

Copied

Thanks for the answer.

it works. just i modified to this:

var textLoc;

var oPgf = vCell.FirstPgf;

textLoc = new TextLoc (oPgf, Constants.FV_OBJ_END_OFFSET-1);

doc.AddText (textLoc, '  ');

but seems I need new line ( ' \n'  but this doesn't work) instead of space. I want to add force line break in the cell.

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...
Jan 16, 2019 0
Advocate ,
Jan 16, 2019

Copy link to clipboard

Copied

Then you need to create a new Pgf after the current last one. I know I have done this a long, long time ago and it was surprisingly simple. But I do not have the code for this. Maybe Rick can juimp in here 🙂

The other option would be to find the Unicode character for a line break and use AddText with that. See if that works.

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...
Jan 16, 2019 0
Advocate ,
Jan 16, 2019

Copy link to clipboard

Copied

oDoc.NewSeriesPgf( oPgf );

oDoc being your active document and oPgf the currently last Pgf in the Cell. This adds a new Pgf - which cauaes a new empty line in your cell.

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...
Jan 16, 2019 0
Community Beginner ,
Jan 16, 2019

Copy link to clipboard

Copied

Thanks,

var oPgf = vCell.LastPgf;

doc.NewSeriesPgf(oPgf);

I tried this but it didn't help me.

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...
Jan 16, 2019 0
Adobe Community Professional ,
Jan 16, 2019

Copy link to clipboard

Copied

var textLoc;

var oPgf = vCell.FirstPgf;

textLoc = new TextLoc (oPgf, Constants.FV_OBJ_END_OFFSET-1);

doc.AddText (textLoc, "\x09"); // Add a soft-return

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...
Jan 16, 2019 0
Jacob_AA LATEST
Community Beginner ,
Jan 17, 2019

Copy link to clipboard

Copied

Thanks. I'm still trying. I will write here when it works.

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...
Jan 17, 2019 0