We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Reading all text from docx file

Hi! I'm using your library for reading a text from file that extension is doc.
According to this function com.aspose.words.Node[] paragraphs = doc.getChildNodes(com.aspose.words.NodeType.PARAGRAPH, true).toArray();)
I can read all text from doc files. But using this function I got text only from first 7 pages.

So, I found another example here
(http://www.aspose.com/docs/display/wordsjava/Document+Tree+Navigation# )

public void recurseAllNodes() throws Exception
{
    // Open a document.
    Document doc = new Document(getMyDir() + "Node.RecurseAllNodes.doc");
<span class="code-comment" style="color: rgb(128, 128, 128);">// Invoke the recursive function that will walk the tree.

traverseAllNodes(doc);
}

/**

  • A simple function that will walk through all children of a specified node recursively

  • and print the type of each node to the screen.
    */
    public void traverseAllNodes(CompositeNode parentNode) throws Exception
    {
    // This is the most efficient way to loop through immediate children of a node.
    for (Node childNode = parentNode.getFirstChild(); childNode != null; childNode = childNode.getNextSibling())
    {
    // Do some useful work.
    System.out.println(Node.nodeTypeToString(childNode.getNodeType()));

     <span class="code-comment" style="color: rgb(128, 128, 128);">// Recurse into the node <span class="code-keyword" style="color: rgb(0, 0, 145);">if</span> it is a composite node.
    

if (childNode.isComposite())
traverseAllNodes((CompositeNode)childNode);
}
}


But the result is same I got only first 7 pages from the document.
Example file anon_BG_1_26.docx attachment.
I would be thankful for any help. Thank you

Hi there,

Thanks for your inquiry. Please note that in evaluation mode there are some limitations applied. E.g Aspose.Words injects an evaluation watermark at the top of the document. The document’s content are truncated after a certain number of paragraphs during export.


To
avoid this you can request a free 30-day trial license which removes
these evaluation restrictions. You can request this from here:
http://www.aspose.com/corporate/purchase/temporary-license.aspx

Regarding getting text of document, please use Document.toString(SaveFormat.TEXT) method. Hope this helps you. Please let us know if you have any more queries.