如何保留格式化的书签文字? [英] How to preserve formatted bookmark text?

查看:100
本文介绍了如何保留格式化的书签文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一份有几个书签的文件。每个书签可能包含一些文本,无论是纯文本还是格式化文本(HTML)。现在,每个书签的文本都是从数据库中提取的。然后我下载了这份文件。我做了一些更改,如更改字体颜色,字体大小和下划线字体等。然后我将每个书签文本提取到数据库,并更新每个列,从中我获得相应书签的先前值。在更新之后,我再次使用更新的格式化文本加载文档,但我只获得纯文本而不是格式化文本。



例如我在文档中有3个书签

名称:Vinoth的bookmark.Text是< b> Vinoth< / b>

城市:Chennai的书签。文字是< u> Chennai< / u>

国家:印度的bookmark.Text是< font size ='5'> India< / font>

我使用的是DocumentBuilder.MoveToBookmark(Bookmark.Name)和InsertHtml(Bookmark.Text)获取带有格式化文本的文档,然后下载文档。



现在我正在更新下载文档中的格式化文本,如下所示/>
名称: Vinoth -font尺寸已更改

城市:Chennai-字体前颜色已更改且下划线已删除

Counrty:印度 - 字体样式已更改



在格式化文本中进行更改后,我将所有书签文本更新到数据库使用c#编码。我可以将所有书签的文本保存为纯文本到数据库。我再次使用更新的格式化文本加载文档。但我在结果文件中只有纯文字如下

姓名:Vinoth

城市:Chennai

国家:印度

你能否告诉我使用c#在书签的文本中获取更新的格式化文本的解决方案。



string text = doc.FirstSection.Body.ToString(SaveFormat。 HTML);



将所有文本读入单个字符串变量。我需要单个字符串变量中的每个书签文本。

Hi I am having a document which has several bookmarks. Each bookmark may contain some text either plain text or formatted text(HTML). Now The text for each bookmark is extracted from database. And I download the document. I made several changes such as changing font color, font size and underline the font etc.,. Then I extract each bookmark text to database and I update each column where from I got the previous value for the respective bookmark. After the updation, Again I load the document with updated formatted text but I only got the plain text instead of formatted text.

For Example I have 3 bookmarks in a document
Name: Vinoth whose bookmark.Text is <b>Vinoth</b>
City: Chennai whose bookmark.Text is <u>Chennai</u>
Country: India whose bookmark.Text is <font size='5'>India</font>
I used DocumentBuilder.MoveToBookmark(Bookmark.Name) and InsertHtml(Bookmark.Text) to get the document with formatted text and I download the document.

Now I am updating the formatted text in the downloaded document as follows
Name: Vinoth -font size has changed
City: Chennai-font fore color has changed and underline is removed
Counrty: India-font style has changed

After making changes in the formatted text I update all the bookmark texts to database using c# coding.I can save all bookmark's text as plain text to database. Again I am loading the document with updated formatted text. But I only got plain text in resultant document as follows
Name: Vinoth
City: Chennai
Country: India
Could you tell me the solution to get the updated formatted text in the bookmark's text using c#.

string text = doc.FirstSection.Body.ToString(SaveFormat.Html);

reads all the text into a single string variable. I need each bookmark text in individual string variable.

推荐答案

这篇关于如何保留格式化的书签文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆