Implementation of Node.toString has Changed in Aspose.Words for Java 21.6

Recently we have tried to upgrade to aspose-words 21.6 java version. This resulted in failures, after the investigation we found that we were using toString representation of Node class (Node is abstract class which is inherited by Paragraph, Run and lots of other classes) which has been changed in version 21.6.

Earlier toString implementation of Node class used to return something like Paragraph 0.0.0 (for Paragraph class), Run 5.0.1.0 (for Run class). Now it has been updated to delegate it to Object class which results into representations like com.aspose.words.Paragraph@1debc91c, com.aspose.words.Run@3727f0ee.

I looked at release notes but didn’t find any reference to this change. Could you please elaborate on it and is there any way to restore the earlier implementation?

@rajanpatil

Could you please share some more detail about your requirement along with input and output documents? Please share the use case in which you need Node.toString method. We will then provide you more information about your query.

Thank you Tahir, please take a look at the below code which reproduces the issue.
Run the below code with the following options:

  1. aspose-words 21.6 version
    output: com.aspose.words.Paragraph@207b8649
  2. aspose-words 21.5 version
    output: Paragraph 0.0.0
void testAsposeNodeToString() throws Exception {
    // create document
    Document asposeDocument = new Document();
    DocumentBuilder builder = new DocumentBuilder(asposeDocument);
    builder.write("some text");
    // get paragraph node and print it
    Node paragraphNode = asposeDocument.getChildNodes(NodeType.PARAGRAPH, true).get(0);
    System.out.println(paragraphNode.toString());
  }

@rajanpatil

We reproduced this behavior of Aspose.Words at our end. This is not a bug.

Please share some detail about your requirement along with input and output documents. Perhaps, there is some other way to achieve your requirement.

Did you notice the changes to output? The point I was making is that the output of toString changed between 21.5 and 21.6 releases. That’s because the toString implementation has changed in 21.6 release.

P.S: You can use any document to produce this behavior, it’s not related to specific examples.

@rajanpatil

We logged a ticket for this implementation change in our issue tracking system as WORDSJAVA-2613. We will inform you via this forum thread once there is an update available on it.

The issues you have found earlier (filed as WORDSJAVA-2613) have been fixed in this Aspose.Words for Java 23.6 update.