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

Free Support Forum - aspose.com

How to Insert Text into a given position and hide it

Hi,to all,

I want to insert plain text into main document at a given position and then hide the inserted text based on VB.net 2008 and aspose.words.dll version 14.2. How to implement it?

Thanks in advance!

Ducaisoft

@ducaisoft

Thanks for your inquiry. You can insert the hidden text at any location in the document using Aspose.Words. Please move the cursor to the desired location, set the value of DocumentBuilder.Font.Hidden property as true, and write the text using DocumentBuilder.Write method. Hope this helps you.

Thanks for your answer!
Unfortunately, It doesn’t work by following your tips! My Codes based on VB.net 2008 and aspose.Words.dll Version 14.2 as follow:

Dim doc As New Aspose.Words.Document(sFile)
Dim builder = New DocumentBuilder(doc)
builder.Font.Hidden = True
builder.MoveToParagraph(5, 0)
builder.Write(“This is hidded inserted text!”)
On Error Resume Next
builder.Document.Save(sFile, Aspose.Words.SaveFormat.Doc)

However, the inserted texts in the outputfile display visible not hidded.

How can I implement my objective based an Version 14.2?

@ducaisoft

Thanks for your inquiry. Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.

Please refer to the attachments for the demo files.
Demo.zip (23.1 KB)
file1.docx is the input file for inserting text and then hiding it.
file2.docx is the output file generated by aspose.words.dll version 14.2. However, the inserted text is still visible not hidden.
file3.docx is the correct output. Open the file3.docx by Word Application ,then select all the document, then call the font setting panel, and then uncheck the ‘hide text’ checkbox, the inserted and hidden text will be visible.

@ducaisoft

Thanks for sharing the detail. Please insert the paragraph break after moving the cursor to the paragraph as shown below. We have attached the output document with this post for your kind reference. output.zip (7.0 KB)

Dim doc As New Aspose.Words.Document(sFile)
Dim builder = New DocumentBuilder(doc)
builder.MoveToParagraph(5, 0)
builder.Writeln()
builder.Font.Hidden = True
builder.Write(“This is hidded inserted text!”)
On Error Resume Next
builder.Document.Save(sFile, Aspose.Words.SaveFormat.Doc)

It works! Thank you very much!