João Silva
João Silva

Reputation: 581

c# Print document and Printer Queue

I'm doing a service to print hang tags and since I can't test mass printing in here I want to ask if someone that did something similar can answer my questions.

For now I'm using just a Print() call, for exemple:

streamToPrint = new StreamReader(@"C:\printerlog\rootlog2.log");
try
{
    printFont = new Font("Arial", 10);
    PrintDocument pd = new PrintDocument();
    pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
    // Print the document.
    pd.PrinterSettings.PrinterName = "HP LaserJet M1522 series PCL6 Class Driver";
    pd.Print();
    }
    finally
    {
        streamToPrint.Close();
    }
(...)

This is working but I think it isn't the best pratice in here due the printing queues. Anyone can tell me if I just use this method, will this be added to the printing queue or I should be worried in what would happen if the printer is busy?

Thank you in advance.

Upvotes: 0

Views: 2044

Answers (1)

BugFinder
BugFinder

Reputation: 17868

Print should submit to queue. However, if you wish to test it to prove to yourself like all of us often end up doing the best way is to write some test code to prove to yourself it adds to a queue.

In this case, I would do 1 print job and tell it to print say 20 copies. (not submit 20 copies of the same job), then immediately tell it to do another print job. if the second is queued, you know it queues, success is yours. If it fails to queue then you know print does and you need a new plan.

I've always taken the stance when in doubt work it out.

Upvotes: 1

Related Questions