Free Support Forum - aspose.com

Numbered list styles are not being imported correctly when using the KeepSourceFormatting import mode

Hello,

I also have hit this issue. Numbered list styles are not being imported correctly when using the KeepSourceFormatting import mode, with lists incorrectly continued. This scenario occurs when importing documents into a master document with DocumentBuilder.

I have been developing an proof-of-concept using Aspose.Words .NET 18.10 and this issue has had me scratching my head for a couple of days. Rolling the package back to 17.6 fixes the problem. If it weren’t for this post I would have never have known.

@Daniel9999999,

Thanks for your inquiry. To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document(s)
  • Aspose.Words 18.10 generated output DOCX file showing the undesired behavior
  • Your expected DOCX Word document showing the correct output. You can create expected document by using Aspose.Words 17.6.
  • Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words.dll files in it to reduce the file size.

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

Please see attached .NET Core 2.2 Console application that reproduces the issue.

Current behaviour: source documents with numbered lists when inserted into a host document do not keep their individual number sequence (the list sequences are joined).
Desired behaviour: each source document retains their individual list numbering when inserted into a host document.

The attached console app uses DocumentBuilder to insert three source documents with ImportFormatMode.KeepSourceFormatting into a host document.

  • Host document: host.docx
  • Sources: merge1.DOC, merge2.DOC, merge3.DOC
  • Output: output.docx
  • Expected: expected.docx

output.docx generated with Aspose.Words for .NET 19.10.
expected.docx generated with Aspose.Words for .NET 17.6

ThanksReproListNumberingIssue.zip (214.4 KB)

My analysis:

output.docx contains one style named MEDIA, which is the style responsible for the numbered lists. This style references a single list Id. I suspect this is why the lists are continued.

expected.docx contains duplicated MEDIA styles, MEDIA0, MEDIA1, MEDIA2…, one for each input document. Each style references a different list Id. This is consistent with the ImportFormatNode behaviour specified here.

 <w:style w:type="paragraph" w:styleId="MEDIA" w:customStyle="1">
    <w:name w:val="MEDIA" />
    <w:basedOn w:val="Normal" />
    <w:rsid w:val="006C7A68" />
    <w:pPr>
      <w:numPr>
        <w:numId w:val="1" />
      </w:numPr>
      <w:tabs>
        <w:tab w:val="num" w:pos="360" />
      </w:tabs>
      <w:spacing w:after="120" />
      <w:ind w:left="340" w:hanging="340" />
      <w:jc w:val="both" />
    </w:pPr>
    <w:rPr>
      <w:snapToGrid w:val="0" />
      <w:sz w:val="24" />
      <w:szCs w:val="20" />
      <w:lang w:eastAsia="en-US" />
    </w:rPr>
  </w:style>

@Daniel9999999,

Thanks for the additional information. 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. The ID of this issue is WORDSNET-19349. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

A post was split to a new topic: ‘No Bullets or Numbering’ setting in the imported linked style ie to ‘inherit’ Bullets and numbering from the ‘based on’ parent styles’

@Daniel9999999,

I see that you have posted a reply here; regarding WORDSNET-19349, your issue is currently pending for analysis and is in the queue. We will inform you via this thread as soon as this issue will be resolved in future. We apologize for any inconvenience.

1 Like

Thanks Awais,

cheers,
Daniel

@Daniel9999999,

Regarding WORDSNET-19349, it is to update you that we have completed the analysis of this issue. Please see the following analysis details:

Put simply, MS Word loses numbering for specified case. Aspose.Words provides “KeepSourceNumbering” option which may be used to preserve source numbering (this option is missing in the MS Word and added to satisfy customer’s needs). Please check the following code for example:

DocumentBuilder builder = new DocumentBuilder(new Document(@"ost.docx"));
builder.MoveToDocumentEnd();

ImportFormatOptions options = new ImportFormatOptions();
options.KeepSourceNumbering = true;

builder.InsertDocument(new Document("merge1.DOC"), ImportFormatMode.KeepSourceFormatting, options);
builder.InsertDocument(new Document("merge2.DOC"), ImportFormatMode.KeepSourceFormatting, options);
builder.InsertDocument(new Document("merge3.DOC"), ImportFormatMode.KeepSourceFormatting, options);

builder.Document.Save("output.docx");

Hope, this workaround will help you in the meantime while you are waiting for a fix. We will keep you posted on any further updates.

1 Like