Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Print Picture

Print Picture

Scheduled Pinned Locked Moved C#
questiongraphicshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    The_Soul_Of_Rock
    wrote on last edited by
    #1

    I have a picture on picture box and I want to press a button to print it but it not work how can i correct this: private void button1_Click(object sender, System.EventArgs e) { try { PrintDocument pd = new PrintDocument(); pd.Print(); } catch (Exception ex) { MessageBox.Show("An error occurred while printing", ex.ToString()); } } private void pd_PrintPage(object sender, PrintPageEventArgs ev) { string path = @"D:\PatientImages\10.jgp"; ev.Graphics.DrawImage(Image.FromFile(path), ev.Graphics.VisibleClipBounds); ev.HasMorePages = true; } and i want to print direct to printer so how can i do it? Thanks in advanced Rock Throught The Night

    H 1 Reply Last reply
    0
    • T The_Soul_Of_Rock

      I have a picture on picture box and I want to press a button to print it but it not work how can i correct this: private void button1_Click(object sender, System.EventArgs e) { try { PrintDocument pd = new PrintDocument(); pd.Print(); } catch (Exception ex) { MessageBox.Show("An error occurred while printing", ex.ToString()); } } private void pd_PrintPage(object sender, PrintPageEventArgs ev) { string path = @"D:\PatientImages\10.jgp"; ev.Graphics.DrawImage(Image.FromFile(path), ev.Graphics.VisibleClipBounds); ev.HasMorePages = true; } and i want to print direct to printer so how can i do it? Thanks in advanced Rock Throught The Night

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      First of all, you don't need to reload the Image if it's already in your PictureBox. Just use ev.Graphics.DrawImage(_pictureBox1_.Image, ...). Second, are you getting any errors? Is your MessageBox in your exception handler showing up? Please be specific since your code should be right (except that if you're scaling the image to the page, I'm not sure why you're setting ev.HasMorePages to true).

      Microsoft MVP, Visual C# My Articles

      T 1 Reply Last reply
      0
      • H Heath Stewart

        First of all, you don't need to reload the Image if it's already in your PictureBox. Just use ev.Graphics.DrawImage(_pictureBox1_.Image, ...). Second, are you getting any errors? Is your MessageBox in your exception handler showing up? Please be specific since your code should be right (except that if you're scaling the image to the page, I'm not sure why you're setting ev.HasMorePages to true).

        Microsoft MVP, Visual C# My Articles

        T Offline
        T Offline
        The_Soul_Of_Rock
        wrote on last edited by
        #3

        please show me how to pint the image by using the printer when i pess the print button thanks Rock Throught The Night

        H 1 Reply Last reply
        0
        • T The_Soul_Of_Rock

          please show me how to pint the image by using the printer when i pess the print button thanks Rock Throught The Night

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          Um, call PrintDocument.Print like you already did. If you want to know how to select a different printer, then you need to read the documentation in the .NET Framework SDK, like for the PrintDocument.PrinterSettings property, which has a printer called PrinterName. You can also use the PrinterSettings.InstalledPrinters static property to get a collection of printers that are installed. All of these properties and methods I've mentioned have plenty of sample source code that's not worth duplicating here.

          Microsoft MVP, Visual C# My Articles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups