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

How to add or remove tab stops using ExtendScript

Advocate ,
Dec 07, 2023 Dec 07, 2023

Copy link to clipboard

Copied

I need to change the tabs in a paragraph via scripting. Here is what I have so far:

 

 

var oaTabs = oPgf.Tabs;
var oaNewTabs = [];
for( n = 0; n < oaTabs.length; n++ )
{
    if( oaTabs[n].x < iLeft || oaTabs[n].x > iRight ) 
        oaNewTabs.push( oaTabs[n] );
}
var oaProps = oPgf.GetProps( );
var i = GetPropIndex( oaProps, Constants.FP_Tabs );
oaProps[i].propVal.tsval = oaNewTabs;
oPgf.SetProps( oaProps );

 

 

 

Replacing the tsval inside the propVal for the paragaph tags does not work. I believe tsval is an alias to an array that is actually there, but what is the property name of the array that I need to replace ? Can this be done at all in this manner ?

 

Thanks for a quick reply

TOPICS
Scripting

Views

100

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 , Dec 07, 2023 Dec 07, 2023

Hi Jang, instead of this:

 

var oaNewTabs = [];

 

try this:

 

var oaNewTabs = new Tabs ();

Let me know if that doesn't work and I will poke at it a little more. Thanks.

 

Votes

Translate

Translate
Community Expert ,
Dec 07, 2023 Dec 07, 2023

Copy link to clipboard

Copied

Hi Jang, instead of this:

 

var oaNewTabs = [];

 

try this:

 

var oaNewTabs = new Tabs ();

Let me know if that doesn't work and I will poke at it a little more. Thanks.

 

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
Advocate ,
Dec 07, 2023 Dec 07, 2023

Copy link to clipboard

Copied

LATEST

Hi Rick,

That works. Thanks. In the meantime I had also found another method. Not using the oPgf.Tabs property but going through GetProps method to assign the tsval to oaTabs. With that method, oaTabs seems to be the pointer to the right tsval structure in oaProps that I needed. Here is the working code:

var oaProps = oPgf.GetProps( );
var p = GetPropIndex( oaProps, Constants.FP_Tabs );
var oaTabs = oaProps[p].propVal.tsval;
var oaNewTabs = [];
for( n = 0; n < oaTabs.length; n++ )
    if( oaTabs[n].x < iLeft + 10 || oaTabs[n].x > iRight - 10 )
        oaNewTabs.push( oaTabs[n] );
while( oaTabs.length ) oaTabs.pop( );
for( n = 0; n < oaNewTabs.length; n++ ) oaTabs.push( oaNewTabs[n] );
oPgf.SetProps( oaProps );

The script is kicking out the tabs at positions between iLeft and iRight (which are calculated from the label text, which might be shorter or longer depending on content and language).

 

Kind regards

4everJang

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