com.aspose.words
Class LayoutCollector

java.lang.Object
    extended by com.aspose.words.LayoutCollector

public class LayoutCollector 
extends java.lang.Object

This class collects mapping of document nodes to layout objects and computes page numbers of nodes.

When you create a LayoutCollector and specify a Document document object to attach to, the collector will record mapping of document nodes to layout objects when the document is formatted into pages.

You will be able to find out on which page a particular document node (e.g. run, paragraph or table cell) is located by using the getStartPageIndex(com.aspose.words.Node), getEndPageIndex(com.aspose.words.Node) and getNumPagesSpanned(com.aspose.words.Node) methods. These methods automatically build page layout model of the document and update fields if required.

When you no longer need to collect layout information, it is best to set the Document property to null to avoid unnecessary collection of more layout mappings.


Constructor Summary
LayoutCollector(Document doc)
           Initializes an instance of this class.
 
Property Getters/Setters Summary
DocumentgetDocument()
voidsetDocument(Document value)
           Gets or sets the document this collector instance is attached to.
 
Method Summary
voidclear()
           Clears all collected layout data. Call this method after document was manually updated, or layout was rebuilt.
intgetEndPageIndex(Node node)
           Gets 1-based index of the page where node ends. Returns 0 if node cannot be mapped to a page.
intgetNumPagesSpanned(Node node)
           Gets number of pages the specified node spans. 0 if node is within a single page. This is the same as getEndPageIndex(com.aspose.words.Node) - getStartPageIndex(com.aspose.words.Node).
intgetStartPageIndex(Node node)
           Gets 1-based index of the page where node begins. Returns 0 if node cannot be mapped to a page.
 

Constructor Detail

LayoutCollector

public LayoutCollector(Document doc)
Initializes an instance of this class.
Parameters:
doc - The document to which this collector instance will be attached to.

Property Getters/Setters Detail

getDocument/setDocument

public Document getDocument() / public void setDocument(Document value)
Gets or sets the document this collector instance is attached to. If you need to access page indexes of the document nodes you need to set this property to point to a document instance, before page layout of the document is built. It is best to set this property to null afterwards, otherwise the collector continues to accumulate information from subsequent rebuilds of the document's page layout.

Method Detail

clear

public void clear()
Clears all collected layout data. Call this method after document was manually updated, or layout was rebuilt.

getEndPageIndex

public int getEndPageIndex(Node node)
                   throws java.lang.Exception
Gets 1-based index of the page where node ends. Returns 0 if node cannot be mapped to a page.

getNumPagesSpanned

public int getNumPagesSpanned(Node node)
                      throws java.lang.Exception
Gets number of pages the specified node spans. 0 if node is within a single page. This is the same as getEndPageIndex(com.aspose.words.Node) - getStartPageIndex(com.aspose.words.Node).

getStartPageIndex

public int getStartPageIndex(Node node)
                     throws java.lang.Exception
Gets 1-based index of the page where node begins. Returns 0 if node cannot be mapped to a page.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.