Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C# (http://www.programmingforums.org/forum16.html)
-   -   Print an image (http://www.programmingforums.org/showthread.php?t=13199)

crawforddavid2006 May 22nd, 2007 11:04 PM

Print an image
 
*sigh* i can figure out how to print text, but no matter what i do, i can't seem to print an image:( :( :'(

:

  1.                 private void PrintReport()
  2.                 {       
  3.                         PrintDocument pd = new PrintDocument();                       
  4.                         PrintDialog pDialog = new PrintDialog();                       
  5.                         pDialog.Document = pd;                       
  6.                         PrintPreviewDialog prevDialog = new PrintPreviewDialog();                       
  7.                         prevDialog.Document = pd;                       
  8.                         pd.PrintPage += new PrintPageEventHandler(Inven_Report);                       
  9.                         prevDialog.ShowDialog();                       
  10.                         if (pDialog.ShowDialog()== DialogResult.OK)
  11.                         {
  12.                                 pd.Print();
  13.                         }       
  14.                 }
  15.  
  16.                 private void Inven_Report(object sender, PrintPageEventArgs e)
  17.                 {
  18.                         Graphics g = e.Graphics;
  19.                         int i = 0;
  20.                         Font myFont = new Font("Arial", 10);               
  21.                         try
  22.                         {
  23.                                 do
  24.                                 {
  25.                                         g.DrawString("Sample Output", myFont, Brushes.Black, 10, 10);
  26.                                         i++;
  27.  
  28.                                 } while (i < 10);
  29.                                 myFont.Dispose();
  30.                         }
  31.                         catch (Exception ex)
  32.                         {
  33.                                 MessageBox.Show(ex.Message.ToString());
  34.                         }
  35.  
  36.                 }


crawforddavid2006 May 23rd, 2007 12:32 AM

What i show in my first post works and prints the text that it says it will, but I dont know how to modify that(if its worth modifying) to make it print what is in a picture box.

crawforddavid2006 May 23rd, 2007 3:45 AM

I have hunted through the MSDN forums, and everything that looks promising, turns out to be for VB .Net, not C#. please could someone help me here?

Ghost May 23rd, 2007 7:27 AM

Go here.

http://www.developerfusion.co.uk/uti...btocsharp.aspx

InfoGeek May 23rd, 2007 7:35 AM

Have you tried this?
:

g.DrawImage(imageRef, new Point(0, 0));

crawforddavid2006 May 23rd, 2007 6:48 PM

Quote:

Originally Posted by InfoGeek (Post 128191)
Have you tried this?
:

g.DrawImage(imageRef, new Point(0, 0));

Your my hero :)


All times are GMT -5. The time now is 2:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC