Line numbering not displayed after changing the orientation to landscape

Issue:

  • Line numbers (serial numbers, ids) are not printed in the generated document, after the page orientation is changed from portrait to landscape.
  • Issue occurs only on the page whose orientation is changed to landscape and on all the pages after that landscape page.

Details:

  • To apply the Line numbers to the generated document, stylesheet is applied using the “.dotx” file. Please refer the same in the 7z file. Cover_Page_-_Kopie.7z (32.3 KB)
  • If we open the Word document in Microsoft Office (Word) or the ASPOSE online doc viewer, the issue is reproduced i.e. line numberings are not displayed.
  • If we open the Word document in some of the other Document Viewers, the issue is NOT reproduced i.e. line numberings are displayed properly.

Please find the attached generated Word document for your reference: Word_9e284fb0-6b3c-4eee-b18b-d179f7055744.docx (113.3 KB)

Request the team to please help us with answers to following questions:

  • The issue in reproduced only in MS Word/ASPOSE online doc viewer. Is this the expected behavior?
  • If not, let us know if we need to follow any specific steps or use any specific API to resolve this issue?

Thanks,
Rishikesh Agam

@rishikeshagam Line numbering is applied per-section in MS Word documents, the same way as page orientation and other page properties. So the landscape page is in a separate section and properties applied in the first section are not applied to it. It looks like this is expected behavior, since MS Word does not show line numbering. However, OpenOffice behaves differently and inherits line numbering from the first section. In Aspose.Words we always consider MS Word behavior as an etalon.
If you need to apply line numbering to all section in your document, you can use code like this:

Document doc = new Document("C:\\Temp\\in.docx");

// Specify line numbers in all sections of the document.
for (Section s : doc.getSections())
{
    PageSetup ps = s.getPageSetup();
    ps.setLineNumberCountBy(1);
    ps.setLineNumberRestartMode(LineNumberRestartMode.RESTART_PAGE);
}

doc.save("C:\\Temp\\out.docx");
1 Like