Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:10:38+00:00 2026-06-10T00:10:38+00:00

I can’t figure out how to start the page numbering at a specific point

  • 0

I can’t figure out how to start the page numbering at a specific point for a section using OpenXML SDK 2.0. Here’s what I see when I reflect on a header in a document using the OpenXML Productivity Tool:

<w:hdr xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
  <w:p w:rsidR="00FC0BC9" w:rsidP="00FC0BC9" w:rsidRDefault="005F46AD">
    <w:pPr>
      <w:pStyle w:val="Header" />
      <w:ind w:right="360" />
      <w:jc w:val="right" />
    </w:pPr>
    <w:r>
      <w:t xml:space="preserve">I-1 Page </w:t>
    </w:r>
    <w:r>
      <w:fldChar w:fldCharType="begin" />
    </w:r>
    <w:r>
      <w:instrText xml:space="preserve"> PAGE  \* Arabic  \* MERGEFORMAT </w:instrText>
    </w:r>
    <w:r>
      <w:fldChar w:fldCharType="separate" />
    </w:r>
    <w:r w:rsidR="00C62387">
      <w:rPr>
        <w:noProof />
      </w:rPr>
      <w:t>1</w:t>
    </w:r>
    <w:r>
      <w:fldChar w:fldCharType="end" />
    </w:r>
  </w:p>

It looks like it’s building the field using a set of Runs, and then by including a Run with a Text value of “1” to start the page numbering for this header to 1 — I should mention the section that uses this header is on page 4.

However, when even when I generate the equivalent using the following code for my own document, Word insists on starting the page numbering at the current page. For example, page 4 starts numbering at page 4, when the desired behavior is that page 4 starts numbering at page 1.

var headerPart = mainDocument.AddNewPart<HeaderPart>(GetHeaderIDFor(actWithScenes.Act, scene));

var header = new Header();
headerPart.Header = header;

header.Append(new Paragraph(
  new ParagraphProperties(new Justification { Val = JustificationValues.Right }),
  new Run(new Text(staticText) { Space = SpaceProcessingModeValues.Preserve }),
  new Run(new FieldChar { FieldCharType = FieldCharValues.Begin }),
  new Run(new FieldCode { Space = SpaceProcessingModeValues.Preserve, Text = " PAGE  \\* Arabic  \\* MERGEFORMAT " }),
  new Run(new FieldChar { FieldCharType = FieldCharValues.Separate }),
  new Run(new RunProperties(new NoProof()), new Text("1")),
  new Run(new FieldChar { FieldCharType = FieldCharValues.End })
));

And here’s the code where I’m adding a section break, which still doesn’t restart the page numbering:

public static Paragraph AppendSectionBreak(Body body, string headerID = null, string footerID = null) {
   var sectionProperties = new SectionProperties();

   if (null != headerID) {
      sectionProperties.Append(new HeaderReference { Id = headerID });
   }

   if (null != footerID) {
      sectionProperties.Append(new FooterReference { Id = footerID });
   }

   var paragraph = new Paragraph(new ParagraphProperties(sectionProperties));

   body.Append(paragraph);

   return paragraph;
}

So, how do I start the page numbering for a section header at an arbitrary value? Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:10:40+00:00Added an answer on June 10, 2026 at 12:10 am

    I figured this out finally. The trick is to use the following code:

    string headerID = "YOUR_HEADER_ID";
    int pageNumberStart = 1
    
    var paragraph = new Paragraph(
       new ParagraphProperties(
          new SectionProperties(
             new HeaderReference { Id = headerID },
             new PageNumberType { Start = pageNumberStart }
          )
       )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can't figure out how to do this in a pretty way : I have
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can I authenticate with just Google account username and password instead of using OAuth?
Can we change the default action of the edit selected row button? Here is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Can anybody shed some light on getDay() in Javascript please. Here datepicker is textbox
Can PHP PDO extension bind nested objects automatically ? I mean using foreign key
Can't work out a way to make an array of buttons in android. This
Can somebody point me a good strategy for security crosscutting concern without AOP for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.