0

I'm trying to make a program that prints a textbox full text. When I'm generating it to a pdf to see the page before I print it some of the text is missing.

This is my code:

private void Print_Click(object sender, EventArgs e)
{
    PrintDialog PD = new PrintDialog();
    PrintDocument PDoc = new PrintDocument();
    PD.Document = PDoc;

    PDoc.PrintPage += new PrintPageEventHandler(PDoc_PrintPage);

    DialogResult result = PD.ShowDialog();

    if (result == DialogResult.OK)
    {
        PDoc.Print();
    }

}

void PDoc_PrintPage(object sender, PrintPageEventArgs e)
{
    Graphics graph = e.Graphics;
    graph.DrawString(textBox1.Text, 
        new Font("Arial", 12), new SolidBrush(Color.Black), 10, 10);
}

This is the text (Just for a test):

hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello

hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello

hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello

this is the textbox screenshot:

enter image description here

This is what I get:

enter image description here

as you can see some of the text is missing. I'm not really familiar with printing so I have no Idea how to solve this problem.

user2992413
  • 77
  • 1
  • 8

1 Answers1

0

It would appear your problem is that you want the text to wrap when printing. Have a look at this previous thread: Automatically Word-Wrapping Text To A Print Page?

Community
  • 1
  • 1
Mike
  • 643
  • 3
  • 10