Like Tree2Likes
  • 1 Post By quzah
  • 1 Post By quzah

need help on batch printing

This is a discussion on need help on batch printing within the C# Programming forums, part of the General Programming Boards category; hello all . i was asked to make a program which takes the forms picture and then prints it. the ...

  1. #1
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493

    need help on batch printing

    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 the user interference!

    so far 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);
            }
    this print function is located in a timer tick event , inwhich the forms information is updated each X seconds and when updated , it is printed and its goes on and on till there are no more information to be updated and hence printed .

    As you can see i tried to re-size the print (sketch ) to match the the form size (which is what is actually to be printed) but no luck!
    i have no idea how im supposed to do that! i searched dozens of articles on google on printing! but none of them were useful to me and neither they covered what i was looking after

    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 the Microsoft's default (virtual?) printer ! - i dont know if this is shown because of that virtual printer or there is the wrong way for batch printing )

    i would be very thankful if any of you guys guide me get through this problem
    thank you all in advance
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1. Configure the printer interface so you can send it jobs to print.
    2. Get your list of things to print.
    3. For each thing to print, get info, set up print job, and print it.

    You need to generalize your items to print, so that it's separate from configuring the printer. Configure the printer, then set it the job to print. Repeat the last until done.

    Quzah.
    Masterx likes this.
    Hope is the first step on the road to disappointment.

  3. #3
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    Thank you verymuch for your reply
    1. Configure the printer interface so you can send it jobs to print.
    ok , about configuring the printer , i already mentioned one of my problems , i cant get the print size changed , it always print in A4 size!!
    2. Get your list of things to print.
    3. For each thing to print, get info, set up print job, and print it.
    are you suggesting that i save each images , and then print these images in another iteration? as you see i just get the image , and then try to print it
    and for the no.3 part , how can i set up the print job , im not sure i got you right ! .
    and ths is the first time im having a project which needs printing! and i couldnt find any sample that demonstrates all of these stuff , most of them ( in my case , all i've seen so far) , do not change the default size of the print paper or even make a queue of jobs for printer , so im just clueless about them , tried MSDN but no luck
    i would appreciate if you guide me more.
    thanks again for your time
    Last edited by Masterx; 09-09-2011 at 02:19 AM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    How to send raw data to a printer by using Visual C# .NET
    PrintDocument.PrinterSettings Property (System.Drawing.Printing)
    http://www.codeproject.com/Articles/...sharp-and.aspx

    There's a whole bunch of stuff regarding printing, but you're going to have to do some digging (or wait until someone shows up that has done this before):

    C# printer - MSDN Search

    I was thinking of something along the lines of:
    Code:
    namespace PrintingStuff
    {
        class Printer
        {
            public void Initialize()
            {
                // initialize your printer
            }
    
            public void Print(PrintJob thisJob)
            {
                // print this job
            }
    
        }
    
        class PrintJob
        {
            // all the info for one particular job, all your file info, size, etc, settings to send to the printer
        }
    
        class Program
        {
            static void Main()
            {
                Printer myPrinter = new Printer();
                PrintJob[] jobList;
    
                myPrinter.Initialize();
                
                // get jobs / set jobList[ x ] = new PrintJob( myfilename or whatever );
    
                // print jobs
                foreach( PrintJob j in jobList )
                {
                    myPrinter.Print( j );
                }
            }
        }
    }
    But I've never done anything with C#, so there's probably a container or something better you could use to do what I'm thinking of.


    Quzah.
    Last edited by quzah; 09-09-2011 at 02:34 AM.
    Masterx likes this.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Batch / FTP
    By bobothesmart in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 05-31-2002, 04:50 PM
  2. Batch file?
    By Silentsharp in forum C++ Programming
    Replies: 1
    Last Post: 02-22-2002, 06:23 PM
  3. batch programming
    By *ClownPimp* in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-14-2002, 01:41 PM
  4. batch files
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-28-2001, 01:01 PM
  5. ftp in batch
    By Unregistered in forum C++ Programming
    Replies: 6
    Last Post: 11-25-2001, 09:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21