New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Stripping inline styles when using the Paste from Word button


Stripping inline styles when using the Paste from Word or Paste from Word strip Font buttons


The ** Paste from Word** icon is using the MSWord setting of the StripFormattingOptions property and the Paste from Word strip Font icon is using the MSWordRemoveAll one. Both paste options strip only the Word formatting (mso- attributes and classes,

tags and other) without cleaning the inline styles. This means that the paragraph margins and other inline style settings will be untouched and this could spoil the appearance of the pasted content when it is displayed on the public site.

To strip the inline styles when pasting content through the Paste From Word *or *Paste From Word strip Font use the following code that will fire the FormatStripper tool with a value of CSS, e.g.

<script type="text/javascript">   
function OnClientCommandExecuted(editor, args)   
   if (!args || !args.get_commandName) return;   
   //The command name   
   var commandName = args.get_commandName();      

   var value = args.get_value();              

   if(commandName=="PasteFromWord" || commandName == "PasteFromWordNoFontsNoSizes")   
   {  "FormatStripper", {value : "CSS"});   

<telerik:radeditor runat="server" ID="RadEditor1"   

More information about the different Paste from Word features of RadEditor is available in this live example: Cleaning Word Formatting.

In this article