Abhilash J A

Abhilash J A

  • 536
  • 2.4k
  • 596.4k

How can I print each image seperately c#.net?

Jan 7 2017 11:39 AM
Hello 
 
 I want to print list of images from list as shown below,
 
 
 I have tried,
 
On button click, 
  1.  int currentPage;  
  2.         ArrayList ListViewItemsData = new ArrayList() { };

  3.  private void btn_click(object sender, MouseButtonEvertArgs e)
  4. {  
  5. PrintDocument pd = new PrintDocument();  
  6.                     pd.PrintPage += new PrintPageEventHandler(PrintImageHandler);  
  7.                     System.Windows.Forms.PrintDialog pdi = new System.Windows.Forms.PrintDialog();  
  8.                     pdi.Document = pd;  
  9.                     if (pdi.ShowDialog() == System.Windows.Forms.DialogResult.OK)  
  10.                     {  
  11.     pd.Print();  
  12. }  
  13. }
  14.   
  15.  private void PrintImageHandler(object sender, PrintPageEventArgs ppeArgs)  
  16.         {  
  17.   
  18. Graphics g = ppeArgs.Graphics;  
  19.             System.Drawing.Image objimage = System.Drawing.Image.FromFile(ListViewItemsData[currentPage].ToString());  
  20.             g.DrawImage(objimage, 50, 50, objimage.Width, objimage.Height);  
  21.             currentPage++;  
  22.             if (currentPage < ListViewItemsData.Count)  
  23.             {  
  24.                 objimage = System.Drawing.Image.FromFile(ListViewItemsData[currentPage].ToString());  
  25.                 g.DrawImage(objimage, 100, 300, objimage.Width, objimage.Height);  
  26.                 currentPage++;  
  27.             }  
  28.             ppeArgs.HasMorePages = currentPage < ListViewItemsData.Count;  
  29.         }  
 How can I do this? Please help me.

Answers (10)