Content Control not getting when append content from one docx to another docx

Hii team ,
when section content append from one document to another then content control not getting in output document.

Snippet:

Aspose.Words.Document SourceDoc = new Aspose.Words.Document(@"C:\\Source.docx");

Aspose.Words.Document OutputDoc = new Aspose.Words.Document(@"C:\\Output.docx");

int[] sectionAccessListIndex = { 1, 2 };
foreach (int i in sectionAccessListIndex)
{
    OutputDoc.Sections[i].RemoveAllChildren();
    OutputDoc.Sections[i].AppendContent(SourceDoc.Sections[i]);
}
OutputDoc.Save(@"C:\\Output.docx");

Output.docx (2.3 MB)
Output.docx (2.3 MB)

@AlpeshChaudhari12345 It looks like you accidently attached output output document twice. Could you please also attach your source document here for testing? We will check the issue and provide you more information.

Output.docx (2.3 MB)

@AlpeshChaudhari12345 Thank you for additional information. I assume that the document with content controls is your source document, since file names of both document you have attached are the same.
Unfortunately, I cannot reproduce the problem, content controls are properly copied into the destination document. Also, please note, the index for accessing sections in the documents is zero-based. So I have modified your test code like this:

Aspose.Words.Document SourceDoc = new Aspose.Words.Document(@"C:\Temp\src.docx");
Aspose.Words.Document OutputDoc = new Aspose.Words.Document(@"C:\Temp\dst.docx");

int[] sectionAccessListIndex = { 0, 1 };
foreach (int i in sectionAccessListIndex)
{
    OutputDoc.Sections[i].RemoveAllChildren();
    OutputDoc.Sections[i].AppendContent(SourceDoc.Sections[i]);
}

OutputDoc.Save(@"C:\Temp\out.docx");

ok thanks for your quick response

1 Like