@alexey.noskov I have a word document in the paragraph having some hyperlinks I want to compare with a document inside the text and my text so I need to ignore the hyperlink in the document while comparing time. Kindly help me asap.
Please find the below mentioned input document.
Input_word document.docx (13.3 KB)
string description = "Please find referenced IMS Policies, Standard Operating Procedures (SOPs), Work Practice (WPs), Guidance Documents (GDs) and Forms, within the IMS Document Library. HR SOPs and WPs can be found in the IMS Document Library and HR Policies, GDs and Forms can be found on the IMS Human Resource Page. Refer to the MMS Global Glossary for terms and acronyms.";
if (paragraph.ToString(SaveFormat.Text).Trim().Equals(description, StringComparison.InvariantCultureIgnoreCase))
{
}
@Princeshivananjappa Hyperlinks are not included into the string returned by paragraph.ToString(SaveFormat.Text)
. Your condition does not pass because your description string does not match the content of the paragraph in your document.
Also, your document has revisions. You can accept revisions before processing the document using Document.AcceptAllRevisions method.
In your document the first paragraph’s content after accepting revisions is the following:
"Please find referenced IMS Policies, Standard Operating Procedures (SOPS), Work Practice (WPs), Guidance Documents (GDS) and Forms, within the IMS Document Library. HR SOPs and WPs can be found in the IMS Document Library."
And your description
string if the following:
"Please find referenced IMS Policies, Standard Operating Procedures (SOPs), Work Practice (WPs), Guidance Documents (GDs) and Forms, within the IMS Document Library. HR SOPs and WPs can be found in the IMS Document Library and HR Policies, GDs and Forms can be found on the IMS Human Resource Page. Refer to the MMS Global Glossary for terms and acronyms."
As you can see the strings are different.
@alexey.noskov My document has hyperlinks. kindly look into it. and I want to ignore hyperlinks.
Please find the below input document.
Input_word document.docx (15.4 KB)
string description = "Please find referenced IMS Policies, Standard Operating Procedures (SOPs), Work Practice (WPs), Guidance Documents (GDs) and Forms, within the IMS Document Library. HR SOPs and WPs can be found in the IMS Document Library and HR Policies, GDs and Forms can be found on the IMS Human Resource Page. Refer to the MMS Global Glossary for terms and acronyms.";
if (paragraph.ToString(SaveFormat.Text).Trim().Equals(description,
StringComparison.InvariantCultureIgnoreCase))
{
}
@alexey.noskov Any update on this?
@Princeshivananjappa Hyperlink in MS Word documents is represented by a filed HYPERLINK. As any other field it is represented like this:
[FieldStart] Field code [FieldSeparator] Field value [FieldEnd]
When you convert a node to string using Node.ToString(SaveFormat.Text)
method, only field value will go into the string. For example:
![](https://forum.aspose.com/uploads/default/73710)
Node.ToString(SaveFormat.Text)
method for such paragraph will return:
"Test hyperlink test"
If you need to completely remove hyperlink from the returned string and get output like this "Test test"
, you should remove hyperlink from the paragraph:
paragraph.Range.Fields.Where(f => f.Type == FieldType.FieldHyperlink).ToList().ForEach(f => f.Remove());