Hi Marc,
Thanks
for your inquiry. The Aspose.Words.Layout namespace provides classes
that allow to access information such as on what page and where on a
page particular document elements are positioned, when the document is
formatted into pages.
Please check “DocumentLayoutHelper” example project in Aspose.Words for .NET examples repository at GitHub. Using DocumentLayoutHelper utility, you can get the lines of a page. Please use following code example to get the total number of lines in HeaderFooterType.HeaderPrimary.
Hope this helps you. Please let us know if you have any more queries.
Document doc = new Document(MyDir + "in.docx");
// Copy primary header contents into first sections's body.
Document docClone = (Document)doc.Clone(true);
docClone.FirstSection.Body.RemoveAllChildren();
docClone.FirstSection.Body.EnsureMinimum();
foreach (Paragraph paragraph in docClone.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary].GetChildNodes(NodeType.Paragraph, true))
{
docClone.FirstSection.Body.AppendChild(paragraph);
}
// Clears the headers and footers of this section.
docClone.FirstSection.ClearHeadersFooters();
// Remove first empty paragraph.
docClone.FirstSection.Body.FirstParagraph.Remove();
RenderedDocument layoutDoc = new RenderedDocument(docClone);
RenderedPage page = layoutDoc.Pages[0];
LayoutCollection<LayoutEntity> lines = page.GetChildEntities(LayoutEntityType.Line, true);
Console.WriteLine("Total lines in HeaderPrimary {0} ", lines.Count);