Results 1 to 4 of 4

Thread: [3.5] Printing to a network printer?

  1. #1

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    [3.5] Printing to a network printer?

    The title pretty much sums this one up... I need this application to print stuff out over a network printer, and I'm not sure where to start. Ultimately it's going to be printing based on a template, and I'm not sure how I'd go about that either, aside from creating a form that's laid out the way I need, then populating it and printing it... any suggestions or good places to start?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [3.5] Printing to a network printer?


  3. #3

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [3.5] Printing to a network printer?

    I think my needs may be slightly different... I've been playing around with a few different methods, and none of them seem to print right. Part of the problem could be that I don't want the printed form to ever be visible... it's something that the user will say 'Print' and it just does it. The code I've been finding thus far seems to rely on taking a snapshot of the form and printing that... such could be a problem..

  4. #4

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [3.5] Printing to a network printer?

    Alright, slight expansion on what's going on... I have the application printing to the proper printer (finally), and for the most part, it seems to be working fine... except that it basically does take a snapshot of the form's area and print that. Great on my screen, but the person who will be using this application has a smaller resolution, and when we tested it, the form was partially hidden by the task bar... and the task bar was printed on top of the form. I think I get why... if it's taking a screenshot of the form, then it makes perfect sense. My question is, how do I fix it? Is there a better way to print out the contents of the form without necessarily taking a screenshot of it? My current code is below:

    C# Code:
    1. void pd_PrintPage(object sender, PrintPageEventArgs e) {
    2.             e.Graphics.DrawImage(memoryImage, 36, 36);
    3.         }
    4.  
    5.         public void Print() {
    6.             Graphics mygraphics = this.CreateGraphics();
    7.            
    8.             memoryImage = new Bitmap(ClientSize.Width, ClientSize.Height, mygraphics);
    9.  
    10.             Graphics memoryGraphics = Graphics.FromImage(memoryImage);
    11.  
    12.             IntPtr dc1 = mygraphics.GetHdc();
    13.             IntPtr dc2 = memoryGraphics.GetHdc();
    14.  
    15.             BitBlt(dc2, 0, 0, ClientSize.Width, ClientSize.Height, dc1, 0, 0, 13369376);
    16.             mygraphics.ReleaseHdc(dc1);
    17.             memoryGraphics.ReleaseHdc(dc2);
    18.  
    19.             pd.Print();
    20.             this.Close();
    21.         }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width