473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can I send multiple documents to print (As a printjob)?

Instead of just sending one document at a time, I need to send multiple
documents as a print job because our laserprinter will only stack and
staple one printjob it receives at a time.
I need to use some of this code:
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.MaximumPage = m_numberOfPages;
printerSettings.MinimumPage = 1;
printerSettings.PrintRange = PrintRange.SomePages;
printerSettings.FromPage = 1;
printerSettings.ToPage = m_numberOfPages;
printerSettings.Copies = 3;
printerSettings.PrinterName = printerName;

PrintDocument pd = new PrintDocument();
m_currentPrintingPage = 1;
m_lastPrintingPage = m_numberOfPages;
pd.PrinterSettings = printerSettings;
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
Thanks,
Trint

Nov 16 '05 #1
9 12891
Unless I'm mistaken, you need to combine the documents into a single
PrintDocument. In the .NET Framework, PrintDocument represents a single
document, or a single print job. Because you are using the PrintPage
event, it should be straight forward to keep the HasMorePages property
set to true until you have rendered all of the actual documents that you
want to combine in to a single PrintDocument.

Bruce Johnson [.NET MVP]
http://www.objectsharp.com/blogs/bruce

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #2
Unless I'm mistaken, you need to combine the documents into a single
PrintDocument. In the .NET Framework, PrintDocument represents a single
document, or a single print job. Because you are using the PrintPage
event, it should be straight forward to keep the HasMorePages property
set to true until you have rendered all of the actual documents that you
want to combine in to a single PrintDocument.

Bruce Johnson [.NET MVP]
http://www.objectsharp.com/blogs/bruce

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
No, HasMorePage*s is just for printing the second or so-on pages of
the first document to print (if it goes beyond one page). For example:
a multi-page Invoice...ok, I want 3 invoices (some with multiple pages,
which is already being handled by HasMorePage*s) to be sent to the
printer as a printjob. Instead, I'm only sending one document, and it
may have multiple pages, to the printer with:
pd.Print();
Thanks,
Trint

Nov 16 '05 #4
No, HasMorePage*s is just for printing the second or so-on pages of
the first document to print (if it goes beyond one page). For example:
a multi-page Invoice...ok, I want 3 invoices (some with multiple pages,
which is already being handled by HasMorePage*s) to be sent to the
printer as a printjob. Instead, I'm only sending one document, and it
may have multiple pages, to the printer with:
pd.Print();
Thanks,
Trint

Nov 16 '05 #5
What I'm suggesting is that you create a state machine within your
PrintPage event handler. Say you have three separate documents being
generated out of three instances of the same class. At the module
level, keep track of the current document instance. Then within the
PrintPage event simply invoke the PrintPage method for the current
document instance. Something like the following.

DocumentToPrint[] docs = new DocumentToPrint[3];
int currentDoc = 0;

private void PrintPage(Object sender, PrintPageEventArgs e)
{
docs[currentDoc].PrintPage(sender, e)
if (!e.HasMorePages && currentDoc < docs.Length)
{
e.HasMorePages = true;
currentDoc++;
}
}

Bruce Johnson [.NET MVP]
http://www.objectsharp.com/blogs/bruce

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6
Bruce,
I am trying to use this info you gave me yesterday so that I can finish
up on this project...however, I'm not sure how to declair this in a
class and if it will really print all of my documents as one job.
Please look:

public static DocumentToPrint[] docs = new DocumentToPrint[3];

I get this error at compile:
error CS0246: The type or namespace name 'DocumentToPrint' could not be
found (are you missing a using directive or an assembly reference?)

How will I print these documents? Can I do this?

pe.PrintReport(@"\\WEB1\Shipping1"); <<this sets up the first report.
docs[currentDoc] = printerSettings;
Class1.docs[currentDoc].Print();
Class1.currentDoc++;

pe.PrintReport2(@"\\WEB1\Shipping1"); <<this sets up the second report.
docs[currentDoc] = printerSettings;
Class1.docs[currentDoc].Print();
Class1.currentDoc++;

pe.PrintReport3(@"\\WEB1\Shipping1"); <<this sets up the third report.
docs[currentDoc] = printerSettings;
Class1.docs[currentDoc].Print();

///and how do send these all to the printer at one time?
///like this?:
Class1.docs[currentDoc].Print();

Thanks for any help,
Trint

.Net programmer
tr***********@gmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7
I can't tell for sure, because I don't know what the pe object or the
PrintReportn methods do. In the code that I provided, the
'DocumentToPrint' class was a dummy one that would have include the
method that supported the PrintPage event handler.

From what it appears, you have created three separate PrintReport
methods, each of which take a path as a parameter. Inside each of these
methods, I assume that you are using the PrintDocument class to do the
printing. If so, where is/are the methods that support the PrintPage
event?

Bruce Johnson [.NET MVP]
http://www.objectsharp.com/blogs/bruce

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #8
Bruce,

I'm helping Trint out on a completely different thread with what I
think is the same problem in the same program. (Correct me if I'm
wrong, Trint.) If you want to get into the fray, you can find the
other thread here.

If we keep it all together in one place we can probably produce a
solution more quickly. (Or make a bigger mess... one or the other. :)

Nov 16 '05 #9
You're correct. I just followed the other thread and it sounds like you got
much deeper into the problem than I have to this point. With a solution that
is grounded in the same place, the PrintPage method. Wonderfully patient,
you are. And feel free to keep going with the thread. I'll keep an eye out
and kick in if I have anything useful to contribute.

"Bruce Wood" wrote:
Bruce,

I'm helping Trint out on a completely different thread with what I
think is the same problem in the same program. (Correct me if I'm
wrong, Trint.) If you want to get into the fray, you can find the
other thread here.

If we keep it all together in one place we can probably produce a
solution more quickly. (Or make a bigger mess... one or the other. :)

Nov 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: CS | last post by:
Dear all, I would like to know whether it is possible to send multiple files in 1 fax? I noticed from some sample code, I can only specify 1 faxdocument.body in the code. Is there a workaround?...
0
by: trint | last post by:
Instead of just sending one document at a time, I need to send multiple documents as a print job because our laserprinter will only stack and staple one printjob it receives at a time. I need to...
3
by: sham | last post by:
Hi to all, I am using XALAN processor and xslt 2.0 and I have managed to take an XML file and split it into multiple documents. This is done via the Oxygen editor. I now need to write a C#...
2
by: marklawford | last post by:
I've been prototyping a reporting solution using XSLT and Java to transform a number of XML files into different formats (PDF and CSV mainly). The XML comes from a legacy system where a number of...
6
by: shantanu | last post by:
Hi All, I have a requirement to develop a search engine based on some search criteria that will search for the string or statement in all the documents uploaded in the website. The search result...
1
by: kashib | last post by:
What I am looking for is a C# example that can send multiple documents of different formats (eg pdf, doc, docx, jpeg etc)to the printer as one print job, I am not sure of the best approach. Can you...
11
by: londres9b | last post by:
I want to send multiple emails from php with one unique script. The emails are from a mysql database table. How can I achieve this?
7
by: MyWaterloo | last post by:
I am currently using this code to send an appointment to Outlook. It sends the info to a form called "frmAppointments" and then to Outlook. This code works great to send the record that is in focus. ...
0
by: metalheadstorm | last post by:
I have a tcp client - server implementation running in the same program, on different background worker threads. There will be instances of this program on multiple computers so they can send and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.