我可以得到正确的文本与下面的代码。然而,下面的代码是有限制的。它将在一页之后切断任何内容,并且不会显示任何格式。
如果我使用message.Rtf而不是message.Text,它会产生如下RTF代码:
{rtf1 1\ansansicpg1252 1252\deff0 0
如何以格式和多页的形式打印东西?谷歌上的每一个链接都是紫色的,没有用。
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();
}发布于 2014-01-29 21:10:01
这应该对你有用
RTF打印机控制
https://stackoverflow.com/questions/21442551
复制相似问题