我正在使用a RichTextBox来显示RTF文件,其中包含一个超链接.链接文本不是URL(目标是有效的URL).RTF是使用Word创建的.Word和写字板都能正确识别链接(写字板不会启动链接,但会显示相应的手形光标).
当我将RTF加载到RichTextBox链接时,链接显示格式正确(蓝色和下划线),但不是表现得像链接,当光标在链接上移动时它仍然是工字梁,LinkClicked事件不会触发,它实际显示链接后尖括号之间的目标(这似乎不正确).由于链接文本不是URL,DetectUrls因此在这里没有帮助.
有RichTextBox没有正确处理这些链接的原因,或者是一种使它们按预期工作的方法?
这是代码.
TipView.Rtf = tips[tipIndex];
// I've also tried TipView.LoadFile, with identical result
Run Code Online (Sandbox Code Playgroud)
要重现此问题,请使用Word(我正在使用2000)创建一个RTF文档,其中包含一个文本不是URL但是以有效URL为目标的链接,并以编程方式将.rtf文件加载到RichTextBox(我使用的是.NET 2.0)在C#Express 2008中.
您可能会说在stackOverflow中有很多关于此的讨论,但是大多数都比我需要的更复杂,主要用于其他语言.
我有一个MySQL远程数据库,其中我有一个"帮助"表,其中包含用于填充使用此数据库的动态网站的帮助页面的代码.
我决定制作一个Delphi应用程序来管理该网站,而不是通过网站本身来提高速度和安全性.
我想用一个TRichEdit来制作帮助文本并使用简单的东西,如对齐,粗体,斜体和带下划线的样式.我不想使用图片和字体.
如何选择丰富的样式文本并将其转换为HTML以放入远程数据库中的BLOB字段,然后如果我想再次编辑它,则重新转换为富文本?
Notepad ++有一个rtf突出显示的插件吗?为了澄清,我的意思是当一个人打开一个rtf文件作为纯文本时,是否有一个插件突出rtf语句(如"{\ rtf ...}","{\ colortbl ...}"等)它与c ++,c#,html等一起使用,还能够折叠像rtf语句一样的rtf语句块?提前致谢.
我想将100多个RTF文件转换为Wiki Markup,但我只能在网上找到"Wiki to RTF"转换器,甚至可以在StackOverflow上找到它.
我只需要RTF - > Wiki Markup
那里有这样的东西吗?
我需要定期以编程方式将*.rtf文件转换为*.docx.手动,这可以正常使用Word 2007中的另存为...得到的docx表现得很好.以编程方式,我无法让它工作.
我尝试的基本上如下:
......但反方向.我打开*.rtf并使用SaveAs到*.docx,而不是打开*.docx并使用SaveAs到*.rtf.但是,生成的文件不会打开,显然有些东西我不明白.是
wordApp.Documents.Open(@"D:\Bar\foo.rtf")
Run Code Online (Sandbox Code Playgroud)
不是一个合法的事情吗?
任何关于如何做到这一点的想法将不胜感激.
我正在尝试使用基本格式的RichTextBox为我的新测试笔记软件Lilly Notes工作.Brian Lagunas关于这个问题的文章让我朝着正确的方向前进,但是我遇到了一些问题.如果单击带下划线的文本,则会按下"下划线"按钮,因此正在识别状态.但是,如果我将其序列化为RTF然后将其反序列化为RichTextBox,则不会检测到它.由于Lilly Notes中的代码在这里展示并不容易,我创建了一个SSCCE来演示这个问题.
首先,MainWindow.xaml:
<Window x:Class="WpfRichTextBoxUnderline.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="350"
Width="525">
<DockPanel LastChildFill="True">
<Button Name="SaveAndReloadButton"
Content="Save and Reload"
DockPanel.Dock="Bottom"
Click="SaveAndReloadButton_Click" />
<ToggleButton Name="UnderlineButton"
DockPanel.Dock="Top"
Width="20"
Command="{x:Static EditingCommands.ToggleUnderline}"
CommandTarget="{Binding ElementName=RichText}">
<ToggleButton.Content>
<TextBlock Text="U"
TextDecorations="Underline" />
</ToggleButton.Content>
</ToggleButton>
<RichTextBox Name="RichText"
SelectionChanged="RichTextBox_SelectionChanged" />
</DockPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)
这就是它的样子:

在代码隐藏中,我有代码来检测选择更改时的格式状态,并相应地更新下划线按钮的状态.这与Brian Lagunas的方法没什么不同.
private void RichTextBox_SelectionChanged(object sender, RoutedEventArgs e)
{
if (this.RichText.Selection != null)
{
object currentValue = this.RichText.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
this.UnderlineButton.IsChecked = (currentValue == DependencyProperty.UnsetValue) ? false : currentValue != …Run Code Online (Sandbox Code Playgroud) 我是python语言的新手,我有一个任务是使用python将rtf转换为pdf.我用谷歌搜索并找到了一些代码 - (不完全是rtf到pdf)但我尝试了它并根据我的要求改变了它.但我无法解决它.
我使用了以下代码:
import sys
import os
import comtypes.client
#import win32com.client
rtfFormatPDF = 17
in_file = os.path.abspath(sys.argv[1])
out_file = os.path.abspath(sys.argv[2])
rtf= comtypes.client.CreateObject('Rtf.Application')
rtf.Visible = True
doc = rtf.Documents.Open(in_file)
doc.SaveAs(out_file, FileFormat=rtfFormatPDF)
doc.Close()
rtf.Quit()
Run Code Online (Sandbox Code Playgroud)
但它抛出以下错误
Traceback (most recent call last):
File "C:/Python34/Lib/idlelib/rtf_to_pdf.py", line 12, in <module>
word = comtypes.client.CreateObject('Rtf.Application')
File "C:\Python34\lib\site-packages\comtypes\client\__init__.py", line 227, in CreateObject
clsid = comtypes.GUID.from_progid(progid)
File "C:\Python34\lib\site-packages\comtypes\GUID.py", line 78, in from_progid
_CLSIDFromProgID(str(progid), byref(inst))
File "_ctypes/callproc.c", line 920, in GetResult
OSError: [WinError -2147221005] Invalid class string
Run Code Online (Sandbox Code Playgroud)
谁能帮我这个?如果有人能找到更好,更快的方法,我真的很感激.我有大约200,000个文件要转换.
Anisha
我尝试转换RTF格式的纯文本.因此,我使用RichTextBox(WinForms).
有关方法将RTF-Markup作为字符串.
现在,我想在标记中插入行间距.我发现有2个参数:
- \slX (Space between lines in twips)
- \slmultX (either 0 or 1)
Run Code Online (Sandbox Code Playgroud)
如果我设置\slmult0,行间距高于文本行.
当我设置时\slmult1,行间距低于文本行.
我用以下方式计算间距:
(lineSpacing + fontSize)*20
Run Code Online (Sandbox Code Playgroud)
当我切换\slmult0到\slmult1,我确定,线距离小于\slmult0.
有人知道这种行为的原因吗?我需要用另一个公式计算吗?
我有一个字符串:
String stringContent="{\\*\\listtable{\\list{\\listlevel{\\leveltext}{\\levelNumber}}}}"
Run Code Online (Sandbox Code Playgroud)
如何在每个传递中逐个选择所有封闭括号的值,如下所示:
"{\\levelNumber}"
"{\\leveltext}"
"{\\listlevel{\\leveltext}{\\levelNumber}}"
"{\\list{\\listlevel{\\leveltext}}}"
"{\\*\\listtable{\\list{\\listlevel{\\leveltext}}}}"
Run Code Online (Sandbox Code Playgroud)
到目前为止我已经这样做了:
public class StringExtracter {
public String stringofObject(Section parentSectionObject, String stringContent) {
Stack stack=new Stack();
String returnString = "";
char arr[] = stringContent.toCharArray();
for(int i=0;i<=arr.length;i++){
while(arr[i]!='}'){
if(arr[i]=='{'){
stringContent=stringContent.substring(i+1);
returnString=stringContent;
System.out.println(stringContent);
braces=true;
Section sectionObject=new Section(parentSectionObject,stringContent);
stack.push(arr[i]);
}
}
return returnString;
}
Run Code Online (Sandbox Code Playgroud)
但问题是它没有}像这样检测到这个权利.我该怎么做?
截至目前的输出:
\*\listtable{\list{\listlevel{\leveltext}{\fefw}}}}
\list{\listlevel{\leveltext}{\fefw}}}}
\listlevel{\leveltext}{\fefw}}}}
\leveltext}{\fefw}}}}
\fefw}}}}
Run Code Online (Sandbox Code Playgroud)