Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue May 28, 2019 3:55 am

Im trying to hide a text content control in word.
Here is a code snippet:

Code: Select all
Document doc = new Document();

var paraInserted = new Paragraph(doc);
var sd = new StructureDocumentTagInline(doc);
paraInserted.ChildObjects.Add(sd);
sd.SDTProperties.SDTType = SdtType.Text;
var text = new SdtText(true);
sd.SDTProperties.ControlProperties = text;
sd.SDTProperties.Tag = "sample";
var rt = new TextRange(doc);
rt.CharacterFormat.Hidden = true;
rt.Text = "sample text";
sd.SDTContent.ChildObjects.Add(rt);

doc.LastSection.Paragraphs.Add(paraInserted);

doc.SaveToFile("output.docx", FileFormat.Docx);


What happens is, it only hides the text within the content control but not the content control itself. Is there a way to hide the content control itself? An alternative I could think of is hiding the paragraph where the content control resides. Is it possible to hide a paragraph itself and not just the Text?

vtoriox
 
Posts: 2
Joined: Tue May 28, 2019 3:39 am

Tue May 28, 2019 7:37 am

Hello,

Thanks for your inquiry.
Sorry your requirement can not be achieved in our Spire.Doc, since our Spire.Doc is based on MS Word. Even in MS Word, it also doesn't support hiding the content control or hiding the paragraph where the content control resides. It just supports hiding the text. Hope you can understand!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc