Alignment of text in header

Home Forums WordprocessingML Alignment of text in header

This topic contains 1 reply, has 2 voices, and was last updated by  Eric White 7 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3452

    sahil joshi
    Participant

    Hello Eric ,

    I want to write a code which makes alignment of some text in left and some in right of paragraph.
    Means below should be under header part.

    Document Name Today’s Date
    ——————————————————————

    How can I achieve it ?

    Thanks in advance !!

    #3453

    Eric White
    Keymaster

    Hi,

    The best way to accomplish this is by using tabs.

    When you need to learn about the markup for any specific feature of Word and Open XML, the best approach is to use that shown in the following screen-cast:

    How to Research Open XML Markup

    The idea here is to set tabs for the locations where you want text to align, and then use tabs between your content, so that the content aligns under the header information.

    First, you will want to show the ruler, so that you can set tabs. On the View tab of the ribbon, in the “Show” section, you click the Ruler checkbox.

    Then set the tabs as appropriate for your content.

    Create a document that is a prototype of how you want your generated document to look.

    Use the Open XML Package Editor Power Tool for Visual Studio to examine the markup, as shown in the above screen-cast. See this link for more information. It is screen-cast 4 in the series:

    Introduction to Open XML Screen-Cast Series

    <w:p>
      <w:pPr>
        <w:tabs>
          <w:tab w:val="left"
                  w:pos="2880"/>
        </w:tabs>
      </w:pPr>
      <w:r>
        <w:t>In column 1</w:t>
      </w:r>
      <w:r>
        <w:tab/>
        <w:t>In column 2</w:t>
      </w:r>
    </w:p>

    You can see the position of the tab in the w:pPr/w:tabs element.

    You can see the location of the tab in the paragraph – it is the w:tab element that is a child of the w:r element.

    When we look at the header part, we see the following, which is identical to the markup in the main document part:

    <w:p>
      <w:pPr>
        <w:pStyle w:val="Header"/>
        <w:tabs>
          <w:tab w:val="left"
                  w:pos="2880"/>
        </w:tabs>
      </w:pPr>
      <w:r>
        <w:t>Heading 1</w:t>
      </w:r>
      <w:r>
        <w:tab/>
        <w:t>Heading 2</w:t>
      </w:r>
    </w:p>
    

    Those tabs are in TWIPS, which is 1/20 of a point. That is the unit of measure for those tabs.

    In addition to watching all of the screen-casts in the Introduction to Open XML series, I also recommend that you watch the screen-casts in the Introduction to WordprocessingML series.

    Cheers, Eric

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.