Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paragraph AppendPageNumber() starting number is wrong for a new section #450

Open
valimaties opened this issue Jan 26, 2023 · 1 comment

Comments

@valimaties
Copy link

Hi.
I have two issues about Section's page counting. I don't know if these are issues from my MS Office 2019 or they are from this library:

  1. After I open the created document, the total amount of pages for a section is not refreshed correctly, and it displays different total numbers while navigating thru pages. It refreshes only after some pages are displayed. For example, if the first section have 11 pages, when I open the document it shows "Pg. 1 of 4", I scroll to the next page and it displays "Pg. 2 of 5", I continue to scroll to the next page and it displays "Pg. 3 of 11". Right now, if I scroll up to second or to the first page it display correctly "Pg 2 of 11" and "Pg 1 of 11".
  2. In a document with multiple sections, the starting number for section starts correctly for first section, which is 1, but from the second section, all sections starts with number 2.
@valimaties valimaties changed the title Paragraph AppendSectionCount() starting number is wrong for a new section Paragraph AppendPageNumber() starting number is wrong for a new section Jan 26, 2023
@XceedBoucherS
Copy link
Collaborator

Hi,

for 2) Page Numbering, if you want each page number to start at 1 for each section of the document, you can do like that:
` var doc = DocX.Create( "test.docx" );
doc.InsertParagraph( "First Paragraph" );

  doc.InsertSectionPageBreak();

  doc.InsertParagraph( "Second Paragraph" ).InsertPageBreakAfterSelf();
  doc.InsertParagraph( "new Paragraph of second section" );


  doc.InsertSectionPageBreak();

  doc.InsertParagraph( "Third Paragraph" );

  foreach( var section in doc.Sections )
  {
    section.PageNumberType = new PageNumberType() { PageNumberStart = 1 };
  }
  doc.AddHeaders();
  doc.Headers.Odd.InsertParagraph( "Page " ).AppendPageNumber( PageNumberFormat.normal ).Append( " of " ).AppendPageCount( PageNumberFormat.normal, true );


  doc.Save();`

If you still have issues with page numbers, please send a sample showing the issue.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants