Content Control contents setting from one document to another

Hi,
We are consolidating the word documents reports. These have content controls. While copying content control contents from one document to another, it is copying fine
but couple of issues.

  1. It get locked and cannot edit it.
  2. Above the text and right side more space
    I attached one doc with screenshots details. Appreciate your help on this.
    Thanks

Code

if (nodeType == NodeType.PARAGRAPH)
{
    Paragraph paragraph = (Paragraph)node;
    paragraph.removeAllChildren();
    Run run = new Run(masterDocument);
    run.setText(contentControlContent);
    paragraph.appendChild(run);
}

@hussain2023 Could you please attach your input and output documents here for our reference? We will check the issue and provide you more information. Unfortunately, it is not possible to analyze the problem using screenshots.

Please find attached
Search for below text in both

Section 5 summary narrative

5.3.1 evidence

5.3.1 finding

5.3.1 CAR

@hussain2023 In your output document SDTs are marked with StructuredDocumentTag.IsShowingPlaceholderText . That is why text is not editable in the output document and is selected when you click on SDT. To prevent highlighting whole SDT content when it is clicked in MS Word, it is required to set StructuredDocumentTag.IsShowingPlaceholderText property to false.
It looks like SDTs are recreated in the output document. When StructuredDocumentTag node is created from scratch, it’s IsShowingPlaceholderText is set to true by default. To stop treating the SDT content as a placeholder text it is require to set this property to false.

Hi,
Thanks for this, non-editable issue is resolved.
Another issue is text is inserting at second line, first line is empty. Can you please help on this ?
Thanks

@hussain2023 Could you please share the simple console application that will allow us to reproduce the problem on our side?

Hi,
We were using ControlChar.LINE_BREAK in code which was causing issue, removed this and it fixed the issue.
Thanks for your support.

1 Like