NodeImporter breaks padding

Hi there

we use Aspose.Words to copy ContentControls of multiple documents into a single resulting docx file.
We use the NodeImporter for this use case like

var importFormatOptions = new ImportFormatOptions { KeepSourceNumbering = true };
var importer = new NodeImporter(
    sourceDocument,
    targetDocument,
    ImportFormatMode.KeepSourceFormatting,
    importFormatOptions
);

var allControls = sourceDocument
    .Document.GetChildNodes(NodeType.StructuredDocumentTag, isDeep: true)
    .OfType<StructuredDocumentTag>()
    .ToList().ForEach(sdt => referenceNode.InsertAfter(importer.ImportNode(sdt, isImportChildren: true), referenceNode));

There are however often a few documents where the contentcontrol is not duplicated as is but is sometimes incorrectly formatted.
In this case the padding is somehow lost despite it still being there inside word.

Original File

After import

Is this some bug or am I missing some instructions ?
AsposeWords_BrokenStyleSample.zip (92.9 KB)

@SimonSchwendele

It seems you are experiencing issues with padding being lost when using the NodeImporter to copy ContentControls from multiple documents into a single DOCX file. This could be due to how the NodeImporter handles certain formatting properties during the import process.

Here are a few suggestions to troubleshoot and potentially resolve the issue:

  1. Inspect Source Document Styles: Ensure that the styles applied to the ContentControls in the source documents are consistent and correctly defined. Discrepancies in styles can lead to unexpected formatting changes.

  2. Manual Adjustment: After importing the nodes, you may need to manually adjust the padding or other formatting properties in the target document. You can access the properties of the StructuredDocumentTag after import and set them explicitly.

  3. Use ImportFormatOptions: If you are using ImportFormatOptions, ensure that you are applying the correct settings that might help retain the formatting you need.

Here’s a minimal example of how you might adjust padding after importing:

var importedNode = importer.ImportNode(sdt, isImportChildren: true);
referenceNode.InsertAfter(importedNode, referenceNode);

// Adjust padding if necessary
if (importedNode is StructuredDocumentTag sdtImported)
{
    sdtImported.Padding = new Padding(10, 10, 10, 10); // Set your desired padding
}

If the issue persists, consider reaching out to the Aspose support forum with specific details about the documents and the formatting issues you are encountering.

Feel free to provide more details if you need additional help!

@SimonSchwendele
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-28759

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.