Document Printing in C#/VS 2010
I want to print a text from file in C#(Visual Studio 2010), but file contains a unformatted text with very long strings; how can i print this file, if long string disappears from for borders and don't print? Give me an example please. Thank you.
priva开发者_开发问答te void printDocumentMenu_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
String text = richTextBoxMenuOutput.Text;
OpenFileDialog openAnnotationFile = new OpenFileDialog();
if (openAnnotationFile.ShowDialog() == DialogResult.OK)
{
StreamReader reader = new StreamReader(openAnnotationFile.FileName);
e.Graphics.DrawString(reader.ReadToEnd(), this.Font, Brushes.Black, 0, 0);
}
}
You can use another overload for DrawString()
, so that the text gets wrapped in a rectangle:
e.Graphics.DrawString(reader.ReadToEnd(), this.Font, Brushes.Black, e.PageBounds);
精彩评论