TextRenderer Text is printing on the left top very small

214 Views Asked by At

I want to print a Multiline Text.
I searched and I found that I can print it with TextRenderer, but the text is printed very small in the left top of the paper. I don´t know why.

Code:

PrintDocument pd = new PrintDocument();
pd.PrintPage += PrintPage_Header;
pd.PrintPage += PrintPage_Adresse;

// pd.Print();

printPrvDlg.Document = pd;
printPrvDlg.ShowDialog();

private void PrintPage_Adresse(object sender, PrintPageEventArgs e)
{
    printFont = new Font("Arial", 10, FontStyle.Bold);
    Size size = TextRenderer.MeasureText(e.Graphics, stringToPrint, this.printFont, proposedSize, TextFormatFlags.WordBreak);
    xPos = new System.Drawing.Rectangle(new Point(22, 150), size);
    TextRenderer.DrawText(e.Graphics, stringToPrint, this.printFont, xPos, Color.Black, Color.White, TextFormatFlags.WordBreak);
}

I can´t find the problem.

0

There are 0 best solutions below