2013-08-30 97 views
0

我有一些RTF文本從我的C#應用​​程序,我轉換爲HTML,然後發送到我的PHP文件。 問題是;我在PHP中的所有文本都是Arial,我的RTF的輸出是Tahoma。任何想法如何改變字體家族?RTF到HTML,更改字體家族

這是我到目前爲止的代碼:

string memoValue = inboundSet.Fields["MEMO"].Value.ToString(); 
if (RtfTags.IsRtfContent(memoValue)) 
    {  
    using (RichEditDocumentServer richServer = new RichEditDocumentServer()) 
     { 
     string htmlText = string.Empty; 
     richServer.RtfText = memoValue; 
     htmlText = richServer.HtmlText; 
     callDetail.Memo = htmlText; 
     } 
    } 
else 
    { 
    callDetail.Memo = memoValue; 
    } 

在我的PHP文件,我用這種方式獲得的價值:

echo "<td>Memo:</td><td>".$value->Memo."</td>"; 

我也嘗試了這種方式:

echo "<td>Memo:</td><td class='fonttest'>".$value->Memo."</td>"; 

而在我的CSS中:

.fonttest 
{ 
    font-size:12px; 
    font-family:Arial; 
} 

我的文字一直在尋找這樣的:

enter image description here

這是我的RTF文本是什麼樣子:

enter image description here

+0

你有沒有試圖改變'時代新Roman'和'Calibri'爲'Arial' ?只是一個簡單的事情,我需要問:) –

+0

我已經解決了它。我無法手動更改RTF,因爲我沒有直接訪問C#應用程序的代碼 – Matheno

回答

1

我解決我的問題,通過這種方式:

string memoValue = inboundSet.Fields["MEMO"].Value.ToString(); 
if (RtfTags.IsRtfContent(memoValue)) 
{  
    using (RichEditDocumentServer richServer = new RichEditDocumentServer()) 
    { 
    string htmlText = string.Empty; 
    richServer.RtfText = memoValue; 
    CharacterProperties cp = richServer.Document.BeginUpdateCharacters(richServer.Document.Range); 
    cp.FontName = "Arial"; 
    cp.FontSize = 12; 
    richServer.Document.EndUpdateCharacters(cp); 
    htmlText = richServer.HtmlText; 
    callDetail.Memo = htmlText; 
    } 
} 
+0

bravo .... :) +1 – Irfan

-1

你必須設置字體家庭爲您生成的HTML。您可以通過將CSS樣式應用於Geneted頁面的標題來完成此操作。

嵌入這種風格的標題:

"<style>body {font-family:Arial;}</style>" 
+0

我不轉換整個頁面,它很可能只是1個句子。在我的PHP頁面的CSS中,我確實使用了font-family:arial,但似乎從我的轉換器中得到的這句話並不在乎樣式表 – Matheno