Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.0 C#
i m trying to print lage size of panel like(1024,700).but it not print all area of panel so plz help any one..
Posted 31-Oct-12 20:42pm
Comments
lukeer at 1-Nov-12 3:21am
   
Here[^] is a good hint of how to ask a question so you get a usable answer.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

panel is control it self
so, use this command
 
PrintDialog myPrintDialog = new PrintDialog();
System.Drawing.Bitmap memoryImage = new System.Drawing.Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(memoryImage, panel1.ClientRectangle);
if (myPrintDialog.ShowDialog() == DialogResult.OK)
{
    System.Drawing.Printing.PrinterSettings values;
    values = myPrintDialog.PrinterSettings;
    myPrintDialog.Document = printDocument1;
    printDocument1.PrintController = new StandardPrintController();
    printDocument1.Print();
}
printDocument1.Dispose();
 

 
or scale image if it's not fit into page
 
private void panel1_Click(object sender, EventArgs e)
        {
            PrintDialog myPrintDialog = new PrintDialog();
            memoryImage = new System.Drawing.Bitmap(panel1.Width, panel1.Height);
 
//scaling into small size
            memoryImage.SetResolution(150, 150);
            panel1.DrawToBitmap(memoryImage, panel1.ClientRectangle);
            memoryImage.Save("E:/a.bmp");
            if (myPrintDialog.ShowDialog() == DialogResult.OK)
            {
                System.Drawing.Printing.PrinterSettings values;
                values = myPrintDialog.PrinterSettings;
           
                myPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true;
                printDocument1.DefaultPageSettings = myPrintDialog.PrinterSettings.DefaultPageSettings;
 
                myPrintDialog.Document = printDocument1;
                printDocument1.PrintController = new StandardPrintController();
                printDocument1.Print();
 

            }
            printDocument1.Dispose();
        }
 
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            SizeF sz = new SizeF(e.PageBounds.Width - e.MarginBounds.Width, e.PageBounds.Height - e.MarginBounds.Height);
            PointF p = new PointF((sz.Width) / 70, (sz.Height) / 70);
            e.Graphics.DrawImage(memoryImage, p);
        }
Note : I have tried to print in Papersize is A5
 
Happy Coding!
Smile | :)
  Permalink  
v2
Comments
Shambhoo kumar at 1-Jan-13 5:45am
   
Your coding is good but it also not print all areas of panel..........
Aarti Meswania at 1-Jan-13 6:38am
   
image is big
you should resize/Scale it in a manner that it fits in page while printing
visit...
http://stackoverflow.com/questions/3489010/scaling-image-for-printing
http://www.codeproject.com/Articles/36990/An-Easy-Way-to-Resize-an-Image

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

  Print Answers RSS
0 mhegazy94 488
1 Sergey Alexandrovich Kryukov 375
2 Kornfeld Eliyahu Peter 285
3 Sibeesh KV 251
4 Gihan Liyanage 189
0 Sergey Alexandrovich Kryukov 6,775
1 OriginalGriff 6,696
2 CPallini 5,345
3 George Jonsson 3,599
4 Gihan Liyanage 2,751


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100