Printing an image

Hi everyone,
Can anyone show me a SIMPLE piece of code to print an image

I'm asking because thus far I've found code that would make a rocket scientist wince.Tongue Tied

thanks,
 Ed.


Answer this question

Printing an image

  • JSMARTIN

    thanks, greatfully received.

    Ed.


  • Randy R Jackson

    I don't think it gets much easier than:



    private Bitmap _bmp;

    private void Form1_Load(object sender, System.EventArgs e)

    {

        PrintDocument pd = new PrintDocument();

        pd.PrintPage += new PrintPageEventHandler(this.PrintImage);

        _bmp = (Bitmap)Image.FromFile(Application.StartupPath + "\\test.jpg");

        pd.Print();

    }

    private void PrintImage(Object sender, PrintPageEventArgs e)

    {

        e.Graphics.DrawImage(_bmp,0,0);

    }


     

    edit: Oops, sorry, originally posted VB.NET code instead of C# :)

  • Printing an image