CWordHtmlConverter.ConvertWordToCleanHtml  
 
Class: CWordHtmlConverter
(Method)


 
Declaration
 
C#
public
static string ConvertWordToCleanHtml(string sHtml)
or:
public static string ConvertWordToCleanHtml(string sHtml, int iFormatStyle)
 
 
Visual Basic
Public Shared Function ConvertWordToCleanHtml(sHtml As String) As String
or:
Public Shared Function ConvertWordToCleanHtml(sHtml As String, iFormatStyle As Integer) As String
 
 
Description
A static method that converts HTML with Word tags to a simplified HTML with standard tags. All Word tags are filtered out. The method returns the converted HTML as a string.
 
This method is useful when copying formatted text from Microsoft Word to a HTML editor / e-mail editor via the clipboard. Although Word automatically places a HTML copy of the selected & copied text in clipboard, this HTML can create problems in an HTML editor / e-mail editor because it contains so many Word specific tags. By calling this method you can clean the HTML and have all Word specific tags removed.
 
Parameters
sHtml : Formatted HTML text from Word that must be converted / cleaned.
   
iFormatStyle : Which HTML tags to use for bold and italic text. Choose one of these values:
  
 
1 = Use <b> and <i>
  2 = Use <strong> and <em>

 
This parameter is optional. If this parameter is not specified the first value (1) is used.
 
Return value
The method returns the converted and updated string.
 
Example
 
// Convert and clean HTML with Word tags
string sCleanedHtml = CWordHtmlConverter.ConvertWordToCleanHtml(sHtmlFromWord);

There is a longer example available on this page.

 
 
< Go Back
 
 
SamLogic