8 Replies Latest reply on Feb 25, 2010 7:39 AM by vlansus

    allign paragraph and numbers on same line [CS3]

    vlansus

       

      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[j].parentTextFrames[0].parent;                   
         myTextFrame.parentStory.insertionPoints.item (-1).contents = page.allPageItems[2].paragraphs[0].contents.substr(0,page.allPageItems[2].paragraphs[0].c ontents.length-1);       
         myTextFrame.parentStory.paragraphs[j].applyParagraphStyle (myParagraphStyle, true);
         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].con tents.length-1,page.allPageItems[2].paragraphs[0].contents.length);
         myTextFrame.parentStory.paragraphs[j].applyParagraphStyle (myParagraphStyle, true);

      }

       

      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?

       

        • 1. Re: allign paragraph and numbers on same line [CS3]
          Peter Kahrel Adobe Community Professional & MVP

          > 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

          • 2. Re: allign paragraph and numbers on same line [CS3]
            vlansus Level 1

            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

            • 3. Re: allign paragraph and numbers on same line [CS3]
              Shonkyin Level 3

              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})

              Change tab position as you want in you document.
              Shonky

              • 4. Re: allign paragraph and numbers on same line [CS3]
                vlansus Level 1

                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[j].applyParagraphStyle (myParagraphStyle.tabStops.firstItem(), true);  

                 

                i have done something like this.

                but there is no tab?

                 

                what do i do wrong?

                 

                greetz,

                kim

                • 5. Re: allign paragraph and numbers on same line [CS3]
                  Shonkyin Level 3

                  I think there is no need tabstop within script. Set tab in your paragraph style and apply your style to text.

                   

                  Shonky

                  • 6. Re: allign paragraph and numbers on same line [CS3]
                    vlansus Level 1

                    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

                    • 7. Re: allign paragraph and numbers on same line [CS3]
                      Shonkyin Level 3

                      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[j].parentTextFrames[0].parent;                   
                         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[j].applyParagraphStyle (myParagraphStyle, true);
                         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[j].applyParagraphStyle (myParagraphStyle, true);

                      }

                      Shonky

                      1 person found this helpful
                      • 8. Re: allign paragraph and numbers on same line [CS3]
                        vlansus Level 1

                        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