Impression d'un texte dans RichTextBox
Bonjour
Je veux imprimer un texte dans un richTextBox : nommé rtb, voici le code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
private void toolStripButton1_Click(object sender, EventArgs e)
{
PrintDialog pr = new PrintDialog();
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.PrintPageEvent);
if (pr.ShowDialog()==DialogResult.OK) pd.Print();
}
private void PrintPageEvent(object sender, PrintPageEventArgs ev)
{
Font fonte = new Font("Times New Roman",12);
ev.Graphics.DrawString(rtb.Text, fonte, new SolidBrush(System.Drawing.Color.Black), (ev.PageBounds.Left + 10), ev.PageBounds.Top + 20);
} |
Il n'imprime qu'une partie de chaque ligne sur un format A4; quand il est en fin de ligne sur la feuille A4, il saute à la ligne pour imprimer la ligne suivante sans finir celle qui précède.
Comment paramétrer pour obtenir l'intégralité du texte?
Cordialement.