question

Jack0987-6744 avatar image
0 Votes"
Jack0987-6744 asked JiaYou-MSFT commented

Printing Text

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-print
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HI

Is there any progress on your question?

0 Votes 0 ·

HI

Is there anything to help you?

0 Votes 0 ·
JiaYou-MSFT avatar image
0 Votes"
JiaYou-MSFT answered JiaYou-MSFT edited

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://docs.microsoft.com/en-us/dotnet/api/system.drawing.graphics.drawstring?view=net-5.0



11.png (123.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Jack0987-6744 avatar image
0 Votes"
Jack0987-6744 answered

I am using C# visual studio 2010.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JiaYou-MSFT avatar image
0 Votes"
JiaYou-MSFT answered

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.


image.png (164.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.