Printing Text

Jack0987 1 Reputation point
2021-07-12T17:52:16.977+00:00

I am trying to print text from a single line or multiline text box.

This is what I have so far:

private void printStuff()
{
textBox1.Text = "Hello World";
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == DialogResult.OK)
{
//???
}
} // End private void printStuff()

How is that done?
Can I choose the font and size?
Thanks.

Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
641 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Andy YOU 3,071 Reputation points
    2021-07-13T05:36:42.097+00:00

    HI

    1.Are you using C++ or C# for all your code?

    2.How is that done?
    I think it will print Hello World, if I misunderstand please correct me.

    3.Can I choose the font and size?
    I think it will be something like below code in picture.
    114091-11.png

    Graphics.DrawString(String, Font, Brush, PointF) method
    https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics.drawstring?view=net-5.0

    0 comments No comments

  2. Jack0987 1 Reputation point
    2021-07-15T12:33:52.68+00:00

    I am using C# visual studio 2010.

    0 comments No comments

  3. Andy YOU 3,071 Reputation points
    2021-07-16T01:27:20.007+00:00

    HI

    115234-image.png

    For detail information, we can refer below video.

    Printing Text example in a windows form c#
    https://www.youtube.com/watch?v=nAI-1w9MhwE

    Please Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice.

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments