【问题标题】:How to exchange RichTextBox Contents to HTML如何将 RichTextBox 内容交换为 HTML
【发布时间】:2019-03-27 16:12:46
【问题描述】:

我想将RichTextBoxContents 交换为 HTML。

我使用了aspose.word,但它是演示版。 前任) enter image description here

【问题讨论】:

  • 你想做什么?在 WPF 应用程序中显示 HTML 内容?如果是这种情况,请使用 WebBrowser-Control
  • 不,我想将 RichTextBox 的输入保存为 html 文件
  • 只要稍微了解一下 HTML 是如何工作的,你应该可以很容易地编写自己的解析器,只需几个

    就可以解决一些基本的 rtb 问题跨度>

  • 谢谢,我大致了解了。

标签: html wpf richtextbox


【解决方案1】:

这应该会指导你一个粗略的方向:

string output = "";
Foreach( line in richtextbox.text)
{
  output += $"<p style=\"color:{line.color.name};\">"
  output += line
  ouput += "</p>";
}

应该给你这样的东西:

<p style="color:red;">This is a the line content.</p>

我在用手机,如果语法有点不对,请多多包涵

【讨论】:

  • 其实多亏了你的提示,我才能够成功编码。我真的很感激。
猜你喜欢
  • 2011-02-07
  • 2019-11-20
  • 2011-11-11
  • 2011-08-13
  • 1970-01-01
  • 1970-01-01
  • 2012-05-13
  • 2017-05-29
  • 1970-01-01
相关资源
最近更新 更多