How to Print a document using C#

42
2



In this video tutorial I’m explaining how to print a document using C# codes. How to Print using C#

I’m printing the document to a xps document because it is easy for demonstration. If you like you can change your default printer as your normal printer. So the document will get from your printer as a hard copy.

For your ease of use I have added the complete code as a comment.

Facebook :

If you like you can directly copy and paste the coding from my Facebook page. It’s available as a comment in my video wall post regarding this tutorial.

Nguồn:https://wijstaanvooronzegrondrechten.org/

Xem Thêm Bài Viết Khác:https://wijstaanvooronzegrondrechten.org/cong-nghe

42 COMMENTS

  1. how i print a pdf file?
    i open a pdf file in C# console application but i want to add a print button to print that file.How? plz help me……..

  2. friend good day, I need your help, I saw the video and let me know if you can do in q application cun to load a system made in PHP to print tickeras serial port. I did the whole system but have problems paw print. Thanks in advance

  3. friend good day, I need your help, I saw the video and let me know if you can do in q application cun to load a system made in PHP to print tickeras serial port. I did the whole system but have problems paw print. Thanks in advance

  4. this code will not work for a text that is longer than the page , the text that is supposed to appear on the next page but is cut off and the first page is re printed.

    good tutorial though, thanks

  5. Thanks, Hi chamila, I watched video "How to Print a document using C#". Can you help me ? I want to print label. How to print label from excel with c# ??

  6. Hi, great video, but can you teach me how to print different text on different pages, 
    like textbox1 text on page 1 and textbox 2 text on page 2. Thanks.

  7. How I can fix that?
    https://plus.google.com/u/0/117464171403878629900/posts/4PH7KJFt8Wn?pid=6136069224629943810&oid=117464171403878629900

  8. Hello, your video is really great.
    But I have a little problem. When I clicked on the printing, so I printed dokument, but this dokument has more pages, but I printed only one page. (What's more, the document has no edges and my text goes off the page.) Could you help me, please?

  9. Put inside the int t = 0;

    private void pd_PrintPage(object sender, PrintPageEventArgs ev) {

    int t = 0; // RESET PG COUNT OTHERWISE SECOND TIME WILL SHOW BLANK
    {
    if (t < 1)
    {

    ev.Graphics.DrawString("Hello YouTube. ", new Font("Times New Roman", 14, FontStyle.Bold), Brushes.Black, 20, 225);

    t++;
    if (t < 1)
    {ev.HasMorePages = true;}
    else
    {ev.HasMorePages = false;}
    }
    #printpreview
    #fail
    #second #time
    #printpreviewfailsecondtime  

LEAVE A REPLY

Please enter your comment!
Please enter your name here