C# 使用格式化打印RTF
我可以用下面的代码正确地输出文本。但是,下面的代码有一些限制。它将在一页之后删除任何内容,并且不会显示任何格式 如果我使用C# 使用格式化打印RTF,c#,visual-studio,printing,rtf,C#,Visual Studio,Printing,Rtf,我可以用下面的代码正确地输出文本。但是,下面的代码有一些限制。它将在一页之后删除任何内容,并且不会显示任何格式 如果我使用message.Rtf而不是message.Text,它会输出Rtf代码,如: {\rtf1\ansansicpg1252\deff0 我怎样才能用格式和多个页面打印东西?谷歌上的每个链接都是紫色的,毫无用处 private void printerHandler(object sender, System.Drawing.Printing.PrintPageEventArg
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();
}
这应该对你有用
链接似乎已断开。