Remove the field codes or any hidden text from paragraph.GetText() or paragraph.Range.Text

Hi,

When i use the method Paragraph.GetText() or Paragraph.Range.Text, i am getting the text/content of that paragraph but it includes the filedCodes or References which is not visible to user when he is viewing the document paragraph.

My requirement is to skip/remove all the hidden codes, text from the paraText that are not visible to user when he opens the document and view that paragraph.

Example - When i do para.GetText() i get this content - “"Assignee" is defined in \u0013 REF _Ref48825358 \w \h \* MERGEFORMAT \u0014Section 9.32\u0015.\r”

But when i open the document and looked at the paragraph, i just see only this as shown in below screenshot.

Please let me know how I can achieve retrieve only the content what I see in my document. Thanks.

@KCSR You should simply use Node.ToString method:

string paraText = paragraph.ToString(SaveFormat.Text);
1 Like

Hi,

We have tried with above solution. But it gives a text like below. Its added "Section 9.32"before the paragraph text.
“Section 9.32. “Assignee” is defined in Section 9.32”

It should be
“Assignee” is defined in Section 9.32"

Thanks

Hi Alexey, thanks for your reply. I am also seeing the same result like -

“Section 9.32. “Assignee” is defined in Section 9.32”

@bhavikkabaria23 Could you please attach your input document here for testing? We will check the issue and provide you more information.