Document Content Lost When Loading - Java

Hi, one of our testers found an issue when using our software. Upon investigation I was able to narrow it down to content loss in a very specific content situation.

error.zip (107.0 KB)

The zip file contains two Word documents. The first is input.docx which I took and loaded into Aspose.Words Java and then immediately saved it back out as result.docx. As you can see, the rich text content control disappears.

Any assistance would be greatly appreciated.

1 Like

@joshuahornsby89

As per current Aspose.Words document model, only sections can be inserted into Document node. We already logged this feature request as WORDSNET-13519 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

Please check the detail of StructuredDocumentTag. StructuredDocumentTag can occur in a document in the following places:

  • Block-level - Among paragraphs and tables, as a child of a Body, HeaderFooter, Comment, Footnote or a Shape node.
  • Row-level - Among rows in a table, as a child of a Table node.
  • Cell-level - Among cells in a table row, as a child of a Row node.
  • Inline-level - Among inline content inside, as a child of a Paragraph.
  • Nested inside another StructuredDocumentTag.

@joshuahornsby89

You cannot read the content control that contains the section break in previous versions of Aspose.Words. Starting from Aspose.Words 20.7, you can read such content control. We have added read only properties for content control that contains the section break. You can find the detail of these properties from here:

Please use following code example to get the title of content controls.

var doc = new Document(MyDir + "my_sample.docx");
foreach (StructuredDocumentTagRangeStart tag in doc.GetChildNodes(NodeType.StructuredDocumentTagRangeStart, true))
    Console.WriteLine(tag.Title);

foreach (StructuredDocumentTag tag in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
    Console.WriteLine(tag.Title);

The issues you have found earlier (filed as WORDSNET-13519) have been fixed in this Aspose.Words for .NET 20.7 update and this Aspose.Words for Java 20.7 update.