Highlighted

adjust tab values with script

Explorer ,
May 13, 2020

Copy link to clipboard

Copied

Hi, I have below text frame is there any script to adjust tab between text and Values. Tab length values would be readjusted in script.

 

Система охлаждения                            10,0 л
Моторное масло                           9,5 л
Топливный бак                                            105 л
Гидробак                                           53 л
Гидросистема                                             104 л

 

Result should be as below:

 

Система охлаждения                            10,0 л
Моторное масло                                    9,5 л
Топливный бак                                      105 л
Гидробак                                                53 л
Гидросистема                                        104 л

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi abhijeet,

see into DOM documentation for paragraph.tabStop :

http://jongware.mit.edu/idcs6js/pc_TabStop.html

 

paragraph.tabStops has an add() method where you can define all the property value pairs in one go.

Or you could change the values of an already set tabStop.

 

// Text is selected:
var paragraph = app.selection[0].paragraphs[0];

if( paragraph.tabStops.length == 1 )
{
	paragraph.tabStops[0].properties =
	{
		alignment : TabStopAlignment.LEFT_ALIGN ,
		position : "70mm"
	};
};

if( paragraph.tabStops.length == 0 )
{
	paragraph.tabStops.add
	(
		{
			alignment : TabStopAlignment.LEFT_ALIGN ,
			position : "70mm"
		}
	);
};

 

Before you could also remove all the tab stops of a given paragraph:

paragraph.tabStops.everyItem().remove();

 

Regards,
Uwe Laubender

( ACP )

TOPICS
Scripting

Views

547

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

adjust tab values with script

Explorer ,
May 13, 2020

Copy link to clipboard

Copied

Hi, I have below text frame is there any script to adjust tab between text and Values. Tab length values would be readjusted in script.

 

Система охлаждения                            10,0 л
Моторное масло                           9,5 л
Топливный бак                                            105 л
Гидробак                                           53 л
Гидросистема                                             104 л

 

Result should be as below:

 

Система охлаждения                            10,0 л
Моторное масло                                    9,5 л
Топливный бак                                      105 л
Гидробак                                                53 л
Гидросистема                                        104 л

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi abhijeet,

see into DOM documentation for paragraph.tabStop :

http://jongware.mit.edu/idcs6js/pc_TabStop.html

 

paragraph.tabStops has an add() method where you can define all the property value pairs in one go.

Or you could change the values of an already set tabStop.

 

// Text is selected:
var paragraph = app.selection[0].paragraphs[0];

if( paragraph.tabStops.length == 1 )
{
	paragraph.tabStops[0].properties =
	{
		alignment : TabStopAlignment.LEFT_ALIGN ,
		position : "70mm"
	};
};

if( paragraph.tabStops.length == 0 )
{
	paragraph.tabStops.add
	(
		{
			alignment : TabStopAlignment.LEFT_ALIGN ,
			position : "70mm"
		}
	);
};

 

Before you could also remove all the tab stops of a given paragraph:

paragraph.tabStops.everyItem().remove();

 

Regards,
Uwe Laubender

( ACP )

TOPICS
Scripting

Views

548

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
May 13, 2020 0
Contributor ,
May 13, 2020

Copy link to clipboard

Copied

Look at text.tabstops 

If each line of your sample is a separate paragraph, each one will have its own array of tabstops. Probably a one-item array. Each tabstop has an alignment property, so it's possible to solve your problem by making sure they are all using the same value. Otherwise, look at the postion property and change them all to the same thing. The tricky thing is: How do you decide which tab stop to apply to all the others? The first? Rightmost? Leftmost? 

 

If your paragraphs use the same paragraph style, you can specify alignment and position values for the style.

 

It's been a while since I did any scripting of tabs, but I remember that it gets weird if you have multiple tabstops in a paragraph and then change the position of the first so that it's larger than the second. This would be weird in the InDesign interface, too. If you're sliding tabs to the left, start with the leftmost tab and loop backwards. 

 

Hope this helps

 

Bob

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...
May 13, 2020 0
Adobe Community Professional ,
May 13, 2020

Copy link to clipboard

Copied

I’m not sure you need a script, you can make a Paragraph Style that contains to correct tab stop. Something like this:

 

Screen Shot 8.png

 

With all the text selected apply the style:

 

Screen Shot 10.png

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...
May 13, 2020 1
Adobe Community Professional ,
May 13, 2020

Copy link to clipboard

Copied

Hi abhijeet,

see into DOM documentation for paragraph.tabStop :

http://jongware.mit.edu/idcs6js/pc_TabStop.html

 

paragraph.tabStops has an add() method where you can define all the property value pairs in one go.

Or you could change the values of an already set tabStop.

 

// Text is selected:
var paragraph = app.selection[0].paragraphs[0];

if( paragraph.tabStops.length == 1 )
{
	paragraph.tabStops[0].properties =
	{
		alignment : TabStopAlignment.LEFT_ALIGN ,
		position : "70mm"
	};
};

if( paragraph.tabStops.length == 0 )
{
	paragraph.tabStops.add
	(
		{
			alignment : TabStopAlignment.LEFT_ALIGN ,
			position : "70mm"
		}
	);
};

 

Before you could also remove all the tab stops of a given paragraph:

paragraph.tabStops.everyItem().remove();

 

Regards,
Uwe Laubender

( ACP )

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...
May 13, 2020 0