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

Free Support Forum - aspose.com

Find and replace dynamic Plain Text or HTML


I am using the below line of code to replace the specific text in work document to text/html.

string value1 = "my DB string"; //this value comes from DB which may be plain text or HTML
oDocument.Range.Replace("signature", value1);

In my above statement, you see that value1 holds either plain text or HTML according to my DB column data. If the value1 holds the HTML, the HTML string replaced with word “signature” as it is without formatting.

I have seen the below article to find and replace the html, but how to detect the Replacement value is a plain text or html?



Aspose.Words does not provide API to detect either a string contains HTML or not. However, you can use C# code to check the HTML tags in a string.

Moreover, you can use DocumentBuilder.InsertHtml to insert the HTML and plain text into the document.