Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


adjust tab values with script

Explorer ,
May 13, 2020 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 л

TOPICS
Scripting

Views

759

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
community guidelines

correct answers 1 Correct answer

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

Likes

Translate

Translate
Contributor ,
May 13, 2020 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
community guidelines
Adobe Community Professional ,
May 13, 2020 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
community guidelines
Adobe Community Professional ,
May 13, 2020 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
community guidelines
Explorer ,
May 13, 2021 May 13, 2021

Copy link to clipboard

Copied

LATEST

Hello, I tried using your codes to apply a 3.75mm tab value on my file. Unfortunately it only applies on the first entry. How can I apply the code to the selected text frame with a 100 entries? Thank you in advance

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
community guidelines