HTML text into microsoft word document bookmark - c#

I have a small web rich text editor that have some features like bolb, italic, and so on...
The text generated is html, and I would like to insert that text inside a word document bookmarks.
Putting the text into the bookmarks is not a problem. However, I have problems because of the text format (with the bolds for example).
Is there a fast way to "convert" text from html to doc, or just a way to include html into a word document?
This is an exemple:
<p>Hello <strong>world<strong/></p>
This text should just appear "Hello World" in the word bookmark.
Thanks in advance.

Enclosing the html in ... <\body> tags should do the trick.

Related

C# - Convert HTML String to formated plain text

Is there a way to convert a html string for example content saved using a wysiwyg editor such as tinyMCE to formatted plain text i.e. retain line breaks.
I've been looking at the HTML Agility Pack but there are no examples that show how you can achieve something like the above.
Basically I want send content saved using tinyMCE in an email notification but i need to ensure any styles and formatting saved by tinyMCE don't break the styles in my HTML email hence the need to convert the content to plain text.
Any examples would be appreciated.

Different style format in a single string value

How to have multiple font style in a single string.
I have a big string and i will append that string to a microsoft word from c# windows application.
I want some characters to be bold... some with big font. like that.
I tried with ordinary HTML tags like < b > bold ..< / b> it wont work..
I want string with mixed font styles.
Text BOLD small BIG
I am Exporting that string to a word file from c# windows application as i mentioned.
Help Much appreciated.
the keyword of your question is RTF, RichText format string see
Better Way of Manipulating RichText in C#?
How to convert a string to RTF in C#?
You can use RTF - see "How to paste a Rich Text Format string into Word with Visual Basic Automation" for an example (in VB.Net, but it would work the same in C#)
There is no style for a string. A string is a list of characters, that's all.
If you want to copy/paste a styled text to word, you'll have to export it in another format first. You could use HTML or RTF.
This lib might help you.

How to display RTF text in to tinyMCE editor

I am using tinyMCE editor. I have rtf formatted string in database column which I want to show in the browser editor i.e. tinyMCE. So that, user will edit the text as he wants. But for that I found I need to convert the rtf string in to xml to see it, since my tinyMCE is showing xmls properly. I am able to show the text from rtf string but I misses out the formatting like bold text, red colored text, \n etc. I want to retain all this formatting. How shall I retain the formatting or how shall I display the rtf text with the formatting or how shall I convert rtf text in to xml properly? I want to display rtf text like I am saving it in some rtf file and opening that file in ms word or open office word that way I want to see the format. rtf is Rich Text format.
You should convert your RTF to HTML and use that for TinyMCE, here is a code project article that will get you started :
http://www.codeproject.com/Articles/27431/Writing-Your-Own-RTF-Converter

ajaxcontroltoolkit htmleditor: both cleanup and keep the format?

In an ajaxcontroltoolkit htmleditor, I would like to load an html formatted text from a file, keep its formatting, edit it and resave it.
While editing the text, if the user pastes in some text from ms word, I'd like to strip its formatting (but keep the formatting of the text in the htmleditor)
In my tries I either keep both formattings (formatting in editor anĀ formattingĀ from word), or loose both of them.
Is there a way to only strip the formatting from the pasted text?

put \\scaps in RTF for small caps

I'm using dynamic RichTextBox control in C# 2.0 and I want to insert "\scaps" in RTF so that if the file is saved programatically and then opened in MS-Word certain text be seen smallcaps.
Can anyone tell me the code as how to insert the tag?
Well, you can access the rich text directly through the Rtf property on the rich text box.

Categories

Resources