Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi!!

i need to print groupbox with its content on full page... (its basically a bill).

can someone please guide me..

i have written the code but the PrintPreview shows only half image...

here is the code..
C#
private void prnt_preview_btn_Click(object sender, EventArgs e)
      {
          PrintPreviewDialog ppd = new PrintPreviewDialog();
          
          PrintDocument pd = new PrintDocument();

          pd.PrintPage += new PrintPageEventHandler(print);

          ppd.Document = pd;
        
          ppd.ShowDialog();


      }


 void print(object sender, PrintPageEventArgs e)
      {
          

          int width = 1000;
          int height = 1800;

          //bill_groupbox.Width,bill_groupbox.Height

          Bitmap bmp = new Bitmap(width, height);
          
          Rectangle rec = new Rectangle(0, 0, bill_groupbox.Width,height);
         
          bill_groupbox.DrawToBitmap(bmp, rec);


          e.Graphics.DrawImage(bmp,rec);

          }

i have not done any printing related codeing earlier.. hence,i don't have much experience...
could someone please help me with this...


Thanks in Advance... :)
Posted
Updated 28-Feb-13 4:07am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900