2011-01-31 49 views
1

flowdocment我有存儲在數據庫中具有完全RTF標籤的富文本,就像這樣:將RTF標記文本在代碼隱藏

{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma;}} 
{\colortbl ;\red0\green0\blue0;} 
\viewkind4\uc1\pard\ltrpar\cf1\f0\fs17 Email sent on 10/1... 

我想使這個文本的WPF的FlowDocument源。當我直接將此文本添加到段落中時,我會看到文檔中的所有標籤。

fd = New FlowDocument 

    p = New Paragraph() 
    p.FontSize = 12 
    p.Foreground = Brushes.Black 
    p.FontWeight = FontWeights.Normal 
    p.Inlines.Add(New Run(vVariableWithRTFTagsInIt)) 
    fd.Blocks.Add(p) 

如何告訴FlowDocument我要添加標記的RTF?謝謝。

回答

1

顯然,很多FlowDocument操作都是使用TextRange類完成的。 結帳TextRange.Load Method

TextRange range = new TextRange(fd.ContentStart, fd.ContentEnd); 
range.Load(stream, DataFormats.Rtf);