Inserting documents does not preserve numbering

Hi,

Inserting documents does not preserve numbering in Heading 1. I have found different behavior when inserting documents with Microsoft Word and when inserting over Aspose.Words with UseDestinationStyles ImportFormatMode.

In source documents StyleIssueSourceDocument01.docx and StyleIssueSourceDocument02.docx there are Heading 1 headlines with numbering format on them. That format is not part of Heading 1 style. It is applied after applying style itself.

When inserting documents into destination document - StyleIssueDestinationDocument.docx, headline from source document will be changed as in destination document (this is expected), but numbering is missing (this is not expected, as this is not a part of heading style).

I have tried the same over Microsoft Word with Insert Object - Text from file and I get this with numbering. Also old behavior that we have with OpenXml and AltChunk we have expected behavior.

Code snippet :

public static void Issue()
{
Document destDoc = new Document("StyleIssueDestinationDocument.docx");
Document sourceDoc = new Aspose.Words.Document("StyleIssueSourceDocument01.docx");
Document sourceDoc1 = new Aspose.Words.Document("StyleIssueSourceDocument02.docx");

destDoc.InsertPageBreak();

DocumentBuilder builder = new DocumentBuilder(destDoc);
builder.MoveToDocumentEnd();
builder.InsertDocument(sourceDoc, ImportFormatMode.UseDestinationStyles);
builder.MoveToDocumentEnd();
destDoc.InsertPageBreak();
builder.InsertDocument(sourceDoc1, ImportFormatMode.UseDestinationStyles);

string documentName = Guid.NewGuid() + ".docx";
destDoc.Save(documentName, SaveFormat.Docx);
}

Result document that is not expected: StyleIssueResultDocument.docx

Expected/desired document : StyleIssueDesiredDocument.docx



Hi Rastko,


Thanks for your inquiry. Please attach the following resources here for testing:

  • Your input Word documents StyleIssueSourceDocument01.docx and StyleIssueSourceDocument02.docx
  • Please attach your expected document showing the desired output here for our reference. You can create expected document using Microsoft Word.
  • Aspose.Words generated output document showing the undesired behavior.


As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,

Files are added.


Thanks
Hi Rastko,

Thanks for your inquiry. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-14397. Our product team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi,


is there any update on this ?

Thanks,
Rastko

Hi Rastko,


Thanks for your inquiry. Unfortunately, your issue is not resolved yet. Our product team has completed the analysis and the root cause of this issue has been identified. We will inform you via this thread as soon as this issue is resolved. We apologize for any inconvenience.

Best regards,

Hi team,


do you have estimate for this ?

Thanks,
Rastko

Hi Rastko,


Thanks for your inquiry. Unfortunately, your issue is not resolved yet. We have asked the ETA of this issue from our product team and will update you as soon as any estimates are available. We apologize for your inconvenience.

Best regards,

Hi.

I am using Words V18.1 and still see this behaviour. Has the issue WORDSNET-14397 been fixed? and if so which version?

Many Thanks

David

@TresAmigos,

Unfortunately, your issue is not resolved yet. We are currently reviewing the fix of this issue. We will inform you via this thread as soon as this issue is resolved or any estimates are available. We apologize for any inconvenience.

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

@risajev,

Regarding WORDSNET-14397, it is to update you that we have added a new ImportFormatOptions class with a public property SmartStyleBehavior.

This option starts working when styles clashes upon importing.

When this option is enabled, a source style will be expanded into a direct attributes inside a destination document, if KeepSourceFormatting importing mode is used.
When this option is disabled, a source style will be expanded only if it is numbered. Existing destination attributes will not be overridden, including lists.

This option can be used with a new public method of a DocumentBuilder class:

public Node InsertDocument(Document srcDoc, ImportFormatMode importFormatMode, ImportFormatOptions options)

Simple use-case is as follows:

Document srcDoc = new Document("source.docx");
Document dstDoc = new Document("destination.docx");
 
DocumentBuilder builder = new DocumentBuilder(dstDoc);
builder.MoveToDocumentEnd();
builder.InsertBreak(BreakType.PageBreak);
 
ImportFormatOptions options = new ImportFormatOptions();
options.SmartStyleBehavior = true;
builder.InsertDocument(srcDoc, ImportFormatMode.UseDestinationStyles, options);

Hope, this helps.