We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Turning off content controls in docx documents

Hi,

I have a technical question: while Aspose preserves content controls in docx file generation, we have the need where we do not want them in generated documents. Is there a way to turn off content controls? Thank you for your help.


Hi,


Thanks for your inquiry. You can use the following code to remove content controls before saving.

foreach (StructuredDocumentTag
sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))

sdt.Remove();


I hope, this helps.

Best regards,

Thank you for the quick response. Will it also remove data? Is there a global flag to remove or turn off content controls instead of doing it one by one? Appreciate your help.

Hi,


Thanks for your inquiry. Yes, the code above removes content controls and all their data. I am afraid, there is no global flag to remove or turn off content controls. Could you please attach your input Word document and expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will provide you code to achieve the same using Aspose.Words.

Best regards,