Copy link to clipboard
Copied
I have a little problem with paragraph and numbering.
i'm creating a a little TOC with ownly my Chapters.
What i want to accomplis:
Page nr. Chapter nr.
Chapter 2 1
Chapter 6 2
the Chapter names, is text that is retrieve from my document.
behind the names i want the page number following with a chapter number.
in the example below i have split the paragraph in 2.
outherwise my page number will stand on the next line.
the Chapter nr is not implement in the example, but you got the idea
for (var j= 0; j<foundInstances.length; j++)
{
page = foundInstances
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(0,page.allPageItems[2].paragraphs[0].contents.length-1);
myTextFrame.parentStory.paragraphs
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.name;
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(page.allPageItems[2].paragraphs[0].contents.length-1,page.allPageItems[2].paragraphs[0].contents.length);
myTextFrame.parentStory.paragraphs
}
1. is there a way, so i can align the numbers?
2. or is it only possible to allign ownly 1 of the 2 numbers?
3. is it posssible to give the numbers a different paragraphStyle?
Copy link to clipboard
Copied
> 1. is there a way, so i can align the numbers?
Insert tabs between the chapter name and page number, and between the page number and the chapter number. Then set tab stops in the paragraph style.
> 2. or is it only possible to allign ownly 1 of the 2 numbers?
Yes, you can align many items. Again, insert tabs and set tab stops in the paragraph style.
> 3. is it posssible to give the numbers a different paragraphStyle?
No, it is not. use character styles.
Peter
Copy link to clipboard
Copied
thanks for you replay.
sorry for my late respons.
1. is there a way, so i can align the numbers?
sow what you meen is, when i place tabs in my script and i assign a paragraph style to it that hold 2 stops in the tab section.
than it will allign the numbers on that position?
greetz,
kim
Copy link to clipboard
Copied
Hi Kim,
You can assign right tab in your paragraph style. See attachment.
Or if you want through script then select your text and run below code
app.selection[0].paragraphs.everyItem().tabStops.everyItem().remove();
app.selection[0].paragraphs.everyItem().tabStops.add ({position:50, alignment: TabStopAlignment.rightAlign})
app.selection[0].paragraphs.everyItem().tabStops.add ({position:100, alignment: TabStopAlignment.rightAlign})
Copy link to clipboard
Copied
thanks,
but i have a other question.
now i can add tabs with scripting.
in my first example, i want to place the page number on the first tab.
can i say before i add this page.number that the correct position is on the first tab?
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.name;
myTextFrame.parentStory.paragraphs
i have done something like this.
but there is no tab?
what do i do wrong?
greetz,
kim
Copy link to clipboard
Copied
I think there is no need tabstop within script. Set tab in your paragraph style and apply your style to text.
Shonky
Copy link to clipboard
Copied
i guese my way of thinking is now wrong.
when i place in my paragraph style a right tab.
like you shown in you example a fuw post back.
when the paragraph style is reading the text, how does he know that he must place te number on the first tab?
so i think before i enterd the number that i must say that it must placed on the first tab?
greet,
kim
Copy link to clipboard
Copied
I have not clear what you want. sorry...
But i think you want insert tab within your page no. and chapter no.
here below i have added tab within your code
for (var j= 0; j<foundInstances.length; j++)
{
page = foundInstances
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(0,page.allPageItems[2].parag raphs[0].contents.length-1) + "\t";
myTextFrame.parentStory.paragraphs
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.name + "\t";
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(page.allPageItems[2].paragra phs[0].contents.length-1,page.allPageItems[2].paragraphs[0].contents.length);
myTextFrame.parentStory.paragraphs
}
Copy link to clipboard
Copied
sorry i will try to clear myself
thank any way for the good respons.
when you do.
myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(0,page.allPageItems[2].parag raphs[0].contents.length-1) + "\t";
if you first word is something like this : "supercalifragalisticexpialidocus" en you do then + "\t";
your second word will bee: "Chapter 2" + "\t".
the 2 pagenumbers arrent alling on the same tabposition.
so i was wondering is i place te tab, in the paragraph style.
and at the end of my document i want to rebuild a TOC.
that i can call the paragraph style's tabs, and say the pagenumber must stand on the first tab?
is this possible?
greetz,
kim
Find more inspiration, events, and resources on the new Adobe Community
Explore Now