Aspose.Words does not Import Multi-section Content Control using .NET

Hi Omri,

Thanks for your inquiry.

Aspose.Words document model is not compatible with requested feature. Unfortunately, there is no further news on this feature. This feature is still postponed. We apologize for your inconvenience.

Hi,

any news regarding this issue?

Hi Omri,

Thanks for your inquiry.

Unfortunately, there is no news on this feature. We apologize for your inconvenience.

Hi,

any news regarding this issue?

@omri.suissa,

I shared in my previous post that Aspose.Words document model is not compatible with requested feature. Most probably, this feature will be closed with “Won’t fix” resolution. Unfortunately, there is no further news on this feature. We apologize for your inconvenience.

Hi,
Can we use this code:

to remove the section breaks before importing the StructuredDocumentTag?

@omri-1

Unfortunately, this code example does not help in your case. This code example removes the section breaks after importing the document into Aspose.Words’ DOM.

@tahir.manzoor
This is something that paid support can solve? or this is just how the product works?

@omri-1

Please note that Aspose.Words document model is not compatible with requested feature. We already shared it in this forum thread.

I know, just wanted to make sure if there is anything else we can do to fix this issue.

@omri-1

Please let us know if you have any more queries about Aspose.Words.

@omri-1

In previous versions of Aspose.Words, you cannot read the content control that contains the section break. 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. Hope this helps you.

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-13601) have been fixed in this Aspose.Words for .NET 20.7 update and this Aspose.Words for Java 20.7 update.

It seems that the new version did NOT solve this issue.
You can test it with the original doc in this thread (from 2 years ago…).

var saveOptions = new HtmlSaveOptions
{
    HtmlVersion = Aspose.Words.Saving.HtmlVersion.Html5,
    ExportImagesAsBase64 = true,
    ExportHeadersFootersMode = Aspose.Words.Saving.ExportHeadersFootersMode.None,
    ExportListLabels = Aspose.Words.Saving.ExportListLabels.AsInlineText,
    ExportLanguageInformation = true,
    AllowNegativeIndent = true,
};
var text = string.Empty;
foreach (Aspose.Words.Node textNode in structuredDocumentTag.ChildNodes)
{
    text += textNode.ToString(saveOptions);
}

Still return only some of the elements in case there is a section break.

@omri-1

We have logged new issue as WORDSNET-20808 for your case. We will inform you via this forum thread once there is an update available on this issue. We apologize for your inconvenience.

@omri-1

Regarding WORDSNET-20808, please use the following code example to get the desired output. Hope this helps you.

var html = string.Empty;

var htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions
{
    ExportImagesAsBase64 = true,
    ExportHeadersFootersMode = Aspose.Words.Saving.ExportHeadersFootersMode.None
};

var doc = new Aspose.Words.Document(MyDir + @"11.docx");

foreach (StructuredDocumentTagRangeStart node in doc.GetChildNodes(NodeType.StructuredDocumentTagRangeStart, true))
{
    Console.WriteLine(node.GetChildNodes(NodeType.Table, true).Count);
    html += StdStartToString(node, htmlSaveOptions);
}

File.WriteAllText(MyDir + @"output.htm", html, Encoding.UTF8);
private static string StdStartToString(StructuredDocumentTagRangeStart start, SaveOptions options)
{
    string result = string.Empty;

    foreach (Node node in start)
    {
        if (node.NodeType == NodeType.StructuredDocumentTagRangeStart ||
            node.NodeType == NodeType.StructuredDocumentTagRangeEnd)
            continue;

        result += node.ToString(options);
    }

    return result;
}

Thank you!
It took 5 years and 15 days, but it is solved!

Please note that while it works with node.ToString, it will not work with the “ExtractContent” method:

You may want to update the example method.

1 Like

@omri-1

The StructuredDocumentTagRangeStart.ToString() method does not work. We will discuss the implementation of this method and inform you via this forum thread about any update.

You can add the suggested code in ExtractContent method to achieve your requirement.

The issues you have found earlier (filed as WORDSNET-20808) have been fixed in this Aspose.Words for .NET 21.10 update also available on NuGet.