CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    couple of questions about priniting in C#

    hello all .
    i was asked to make a program which takes the forms picture and then prints it. the form can be of any size and also there must be two modes for printing , a batch print option and a single printing option .

    printing the form was easy but im stuck at the printing section .
    my problems are :
    1.i dont know how i can change the size of the card when printing.!

    2.i have no idea how i can have a batch printing without user interference!

    thank you all in advance

  2. #2
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: couple of questions about priniting in C#

    any help?

  3. #3
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: couple of questions about priniting in C#

    ok i have these functions for printing procedures :
    Code:
    protected void btnPrint_Click(object sender, EventArgs e)
            {
                PaperSize cardsize = new PaperSize("test", this.Width, this.Height);
                PrintDocument pd = new PrintDocument();
                pd.PrinterSettings.Duplex = Duplex.Horizontal;
                PageSettings psetting = new PageSettings();
                psetting.PaperSize = cardsize;
                pd.DefaultPageSettings = psetting;
    
                pd.PrintPage += new PrintPageEventHandler(PrintImage);
                pd.Print();
            }
    Code:
            void PrintImage(object o, PrintPageEventArgs e)
            {
                int x = SystemInformation.WorkingArea.X;
                int y = SystemInformation.WorkingArea.Y;
                int width = this.Width;
                int height = this.Height;
    
                Rectangle bounds = new Rectangle(x, y, width, height);
    
                Bitmap img = new Bitmap(width, height);
    
                this.DrawToBitmap(img, bounds);
                Point p = new Point(100, 100);
                e.Graphics.DrawImage(img, p);
            }
    i call this print function in a timer tick event , inwhich the forms information is updated each X seconds and when updated , it is printed and so on...

    as you see i've tried to first resize the print page to match with the form size , but no luck!
    i have no idea how im supposed to do that! searched couple of articles on google on printing! but nothing useful !
    and the other problem is that , when printing , a window is shown to the user to choose a name and then save the print file ( i currently have no printer installed , so there is only a microsoft default printer ! - will this window just stop showing when an actual printer is installed ? )

    any help ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured