I have some code that prints a string, but if the string is say: "Blah blah blah"... and there are no line breaks, the text occupies a single line. I would like to be able to shape the string so it word wraps to the dimensions of the paper.
private void PrintIt(){
PrintDocument document = new PrintDocument();
document.PrintPage += (sender, e) => Document_PrintText(e, inputString);
document.Print();
}
static private void Document_PrintText(PrintPageEventArgs e, string inputString) {
e.Graphics.DrawString(inputString, new Font("Courier New", 12), Brushes.Black, 0, 0);
}
I suppose I could figure out the length of a character, and wrap the text manually, but if there is a built in way to do this, I'd rather do that. Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…