2014-01-29 49 views
0

我可以使用下面的代碼正確顯示文本。但是,下面的代碼有限制。它會在一頁後切斷任何內容,並且不會顯示任何格式。使用格式化打印RTF

如果我使用message.Rtf,而不是message.Text,它吐出像RTF代碼:

{\ RTF1 \ ansansicpg1252 \ deff0

我怎樣才能得到的東西與格式打印,多比一頁?谷歌上的每一個鏈接都是紫色的,都無濟於事。

private void printerHandler(object sender, System.Drawing.Printing.PrintPageEventArgs e) 
{ 
    StringReader reader = new StringReader(message.Text); 
    float LinesPerPage = 0; 
    float LeftMargin = e.MarginBounds.Left; 
    float TopMargin = e.MarginBounds.Top; 
    string Line = null; 
    Font PrintFont = this.message.Font; 
    SolidBrush PrintBrush = new SolidBrush(Color.Black); 

    LinesPerPage = e.MarginBounds.Height/PrintFont.GetHeight(e.Graphics); 
    RectangleF rect = new RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Right - e.MarginBounds.Left, e.MarginBounds.Bottom - e.MarginBounds.Top); 

    Line = reader.ReadToEnd(); 
    e.Graphics.DrawString(Line, PrintFont, PrintBrush, rect, new StringFormat()); 

    e.HasMorePages = false; 

    PrintBrush.Dispose(); 
} 

回答