473,794 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it possible to combine two PrintDocuments or...

add them into one PrintDocument:
PrintDocument pd1 = new PrintDocument() ;
PrintDocument pd2 = new PrintDocument() ;

PrintDocument pdCombined = new PrintDocument() ;
pdCombined = pd1 + pd2;
pdCombined.Prin t();
Thanks,
Trint

Nov 16 '05
24 8178
Oh, drat. There was a coding error in a snippet I gave you. The copy
logic should read like this:

// If this is the last copy then move to the next page
if (this.m_copy < 3)
{
this.m_copy += 1;
ev.HasMorePages = true;
}
else
{
this.m_copy = 1;

// If the next page is less than or equal to the last p*age,
// print another page.
if (++m_currentPri ntingPage <= m_lastPrintingP age)
ev.HasMorePages = true;
}

Nov 16 '05 #11
Bruce,
I got some errors that I need you to help me work out, since my level of
experience is not as high as yours.
I got a fallthrough error:
'WindowsApplica tion1.Form1.Pri ntReporttoLaser jet' does not contain a
definition for 'm_copy'
on this line:
this.m_copy = this.m_copy(1);
pd.Print();
I got a:
The name 'm_copy' does not exist in the class or namespace
'WindowsApplica tion1.Form1.Pri ntReporttoLaser jet'
on this line:
switch (m_copy)
I got a:
Control cannot fall through from one case label ('default:') to another
on this line:
switch (m_copy)
and this error:
'WindowsApplica tion1.Form1.Pri ntReporttoLaser jet' does not contain a
definition for 'm_copy'
on each of these lines:
if (m_currentPrint ingPage <= m_lastPrintingP age &&
MoveToPage(m_cu rrentPrintingPa ge))
{
// Draw the page
ReportDrawPage( ev.Graphics);
// If this is the last copy then move to the next page
if (this.m_copy < 3)
{
this.m_copy += 1;
}
else
{
this.m_copy = 1;
}

If you can get me going with this, it is much appreciated...
One more thing:
When all three of these invoice copies defalt print to OutPutBin1 (which
is where they now go), they are automatically stapled by this printer.
Also, this printer is dedicated to only doing this one thing, so I don't
have to worry about the other people ever printing to it.
thanks,
Trint


..Net programmer
tr***********@g mail.com

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

In point #2, when I said that you had to declare a new variable,
m_copy, an int, I meant that you had to make it a class member. At the
start of your class:

public class PrintReporttoLa serjet
{
private int m_copy;
....
}

That should solve most of your errors, if not all of them.

The error about not being able to fall through from one case to the
next, in the "switch" statement, is either a red herring, or you forgot
one of the "break" statements. Every case, including the default:,
needs a "break" just before the next case. The "default" case should
consist of one line: "break;" (apart from the comment I put there).

You did get my note about the if (this.m_copy < 3)... missing a line,
didn't you?

Nov 16 '05 #13
Bruce,
Thanks again for your help...I have one error left after changing the
private int m_copy; and the ev.PrinterSetti ngs to pd.PrinterSetti ngs.
Here is the error:
error CS0163: Control cannot fall through from one case label
('default:') to another
On this line:
switch (m_copy).
Thanks.
Bruce, I may have a problem that will change everything that we have
discussed...the third page (the pink one) must NOT have the prices
showing in it (this according to my IT Director). Plus, I may have to
leave the "pd_PrintPa ge" as it originally was because it is already
handling the "if the emf memory stream document (the invoice) has
multiple pages (not copies). Since that is the case, I may have to
revert to my original question "Is it possible to combine multiple
documents and send them as one printdocument to the laserjet 4350tn"?
The reason is:
When I get an object handle (like "pd., pd2. and pd3.") for all three of
these documents, they must all go out as one printjob or one document
because if the laserjet senses that printdocument.p rint has been called
on only one page at a time, it automatically drops one page at a time in
another output bin instead of the "stapler stacker" bin so that all
three copies of the invoice (and the last page will be a separate report
because, eventhough identical to the first two except it has NO prices
on it) can be stapled.
Sooo, here is the REAL question:
Is it possible for me to collect all three documents (pd., pd2. and
pd3.) and combine them into one printdocument before calling
"pd.Print() ;" which will really be comBinedpd's.pr int somehow?
Here is someones idea on that:
DocumentToPrint[] docs = new DocumentToPrint[3];
int currentDoc = 0;

private void PrintPage(Objec t sender, PrintPageEventA rgs e)
{
docs[currentDoc].PrintPage(send er, e)
if (!e.HasMorePage s && currentDoc < docs.Length)
{
e.HasMorePages = true;
currentDoc++;
}
}
If care to help with this [more complex] issue, I REALLY appreciate it.
Thanks,
Trint

..Net programmer
tr***********@g mail.com

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

Please copy your entire (new) pd_PrintPage() method here so that I can
see it. The error you are getting indicates that you are missing a
"break" statement in your "switch" somewhere. I need to see the whole
method in order to find the problem.
Plus, I m*ay have to
leave the "pd_PrintPa ge" as it originally was because it is *already handling the "if the emf memory stream document (the invoice*) has
multiple pages (not copies).


If you followed my instructions carefully, you will find that the new
pd_PrintPage handles multiple copies and multiple pages correctly. Read
my posts again: remember that I said that pd_PrintPage would be called
for:

pd_PrintPage: m_currentPrinti ngPage 1, copy 1
pd_PrintPage: m_currentPrinti ngPage 1, copy 2
pd_PrintPage: m_currentPrinti ngPage 1, copy 3
pd_PrintPage: m_currentPrinti ngPage 2, copy 1
pd_PrintPage: m_currentPrinti ngPage 2, copy 2
pd_PrintPage: m_currentPrinti ngPage 2, copy 3
etc.

If someone is telling you that this new design will print only three
copies for a single invoice, and not print the other pages, then they
are quite simply mistaken. If you want the pages to print in a
different order, then that can be arranged, too.

It is not possible to combine multiple PrintDocuments into one print
job. Can't be done. However, take heart. pd_PrintPage can once again be
adjusted to print multiple documents, each with multiple pages, in
multiple copies. You just need to decide upon the order in which you
want things printed. That is, do you want printing by the document,
then by the page, then by the copy:

Document 1, page 1, copy 1
Document 1, page 1, copy 2
Document 1, page 1, copy 3
Document 1, page 2, copy 1
Document 1, page 2, copy 2
Document 1, page 2, copy 3
Document 2, page 1, copy 1
Document 2, page 1, copy 2
Document 2, page 1, copy 3
etc.

or do you want printing by the document, by the copy, then by the page?

Document 1, page 1, copy 1
Document 1, page 2, copy 1
Document 1, page 1, copy 2
Document 1, page 2, copy 2
Document 1, page 1, copy 3
Document 1, page 1, copy 3
Document 2, page 1, copy 1
Document 2, page 1, copy 2
Document 2, page 1, copy 3
etc.

In other words, for each document, do you want the first page white,
then yellow, then pink, then the next page white, then yellow, then
pink, or do you want the entire document (all pages) printed on white
paper, then the entire document again on yellow paper, then the entire
document again on pink paper, then start the next document?

Finally, as for the pink copy not having the price on it, I will have
to find the post where you posted your code again, but that should be a
relatively easy adjustment. I will post a suggestion shortly.

Nov 16 '05 #15
Trint,

I have a question about your reporting system. Your boss says that the
last page (the pink copy) cannot have the prices on it. How would you
print a whole new report without the prices? In the code you posted
there are lots of calls to objects and methods that are obviously
peculiar to your system. How would you make a call to generate a report
without the prices?

I'm guessing that you would do something different in RenderReport, but
what? Would you pass it a different reportPath to print in a different
format? I need to know this before I can advise you on how to modify
your class in order to print the third copy differently.

Again, I want to impress a couple of things on you:

1. There is no need to undo all of the work you've done over the past
while. You are proceeding in the correct direction to achieve all of
the project's goals. In fact, you are proceeding in the only direction
that will achieve all of your objectives.

2. Proceed step by step. I notice that you didn't do this the last time
when I told you to. :) Get the application working, printing three
copies, even if it's not the page order you want, or the pink copy
still shows the prices. Then, when you have that, make a change, and
test it again. _DO NOT_ attempt to throw all of the changes in at once
and run it with your fingers crossed, hoping that it will miraculously
work. It will not, and that will cost you valuable time and frustrate
you, as I think you've already discovered. I've been doing this for 20
years. Trust me. :)

Nov 16 '05 #16
Bruce, you are right...:) I am working on what you have suggested...I
have to redo my project for the reports first so that they actually
show...in about 40 minutes, I should have this all set...your question:
"How would you print a whole new report without the prices?"

here:
public bool PrintReport3(st ring printerName)
{
this.RenderedRe port = this.RenderRepo rt(@"/Report
PackingList1/Report2");

This function has to be called last to render the 2nd report (which is
the 3rd "copy")...t he 1st and second pages are really just one report
"(@"/Report PackingList1/Report1");"
I'm really trusting you to get me out of this hole...
Thanks,
Trint

Bruce Wood wrote:
Trint,

I have a question about your reporting system. Your boss says that the last page (the pink copy) cannot have the prices on it. How would you
print a whole new report without the prices? In the code you posted
there are lots of calls to objects and methods that are obviously
peculiar to your system. How would you make a call to generate a report without the prices?

I'm guessing that you would do something different in RenderReport, but what? Would you pass it a different reportPath to print in a different format? I need to know this before I can advise you on how to modify
your class in order to print the third copy differently.

Again, I want to impress a couple of things on you:

1. There is no need to undo all of the work you've done over the past
while. You are proceeding in the correct direction to achieve all of
the project's goals. In fact, you are proceeding in the only direction that will achieve all of your objectives.

2. Proceed step by step. I notice that you didn't do this the last time when I told you to. :) Get the application working, printing three
copies, even if it's not the page order you want, or the pink copy
still shows the prices. Then, when you have that, make a change, and
test it again. _DO NOT_ attempt to throw all of the changes in at once and run it with your fingers crossed, hoping that it will miraculously work. It will not, and that will cost you valuable time and frustrate
you, as I think you've already discovered. I've been doing this for 20 years. Trust me. :)


Nov 16 '05 #17
One thing I don't understand is how do I write this?:
Document 1, page 1, copy 1
Document 1, page 1, copy 2
Document 1, page 1, copy 3
Document 1, page 2, copy 1
Document 1, page 2, copy 2
Document 1, page 2, copy 3
Document 2, page 1, copy 1
Document 2, page 1, copy 2
Document 2, page 1, copy 3
Thanks,
Trint

..Net programmer
tr***********@g mail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #18
OK,
I got it exactly as you have said...I fixed the error by puting it this
way:

try
{
///Print from tray 2
///Print from tray 3
///Print from tray 4
// Set the paper source based upon the selection in the combo
box.
// pd.DefaultPageS ettings.PaperSo urce =
// pd.PrinterSetti ngs.PaperSource s[comboBox1.Selec tedIndex =
Class1.counter];

this.m_copy = 1;
Class1.pd.Print ();

private void pd_PrintPage(ob ject sender, PrintPageEventA rgs ev)
{
switch (m_copy)
{
case 1:
//ev.PageSettings .PaperSource = ... ;
ev.PageSettings .PaperSource =
Class1.pd.Print erSettings.Pape rSources[comboBox1.Selec tedIndex =
4];
break;
case 2:
//ev.PageSettings .PaperSource = ... ;
ev.PageSettings .PaperSource =
Class1.pd.Print erSettings.Pape rSources[comboBox1.Selec tedIndex =
5];
break;
case 3:
//ev.PageSettings .PaperSource = ... ;
ev.PageSettings .PaperSource =
Class1.pd.Print erSettings.Pape rSources[comboBox1.Selec tedIndex =
6];
break;
default:
break;
}
ev.HasMorePages = false;
if (m_currentPrint ingPage <= m_lastPrintingP age &&
MoveToPage(m_cu rrentPrintingPa ge))
{
// Draw the page
ReportDrawPage( ev.Graphics);
// If this is the last copy then move to the next page
if (this.m_copy < 3)
{
this.m_copy += 1;
ev.HasMorePages = true;
}
else
{
this.m_copy = 1;
}
// If the next page is less than or equal to the last page,
// print another page.
if (++m_currentPri ntingPage <= m_lastPrintingP age)
ev.HasMorePages = true;
}
}
But it prints one page from tray 4 which is index 6, and draws a second
page from tray 2 index 4.
Thanks,
Trint

Nov 16 '05 #19
Trint,

You have an error in the last part of the pd_PrintPage function. It
should read like this:

if (this.m_copy < 3)
{
this.m_copy += 1
;
ev.HasMorePages = true;

}
else
{
this.m_copy = 1;
// If the next page is
less than or equal to the last p*age,
// print another page.
if
(++m_currentPri ntingPage <= m_lastPrintingP age)
ev.HasMorePages
= true;
}

.... the "if (++m_currentPri ntingPage <= m_lastPrintingP age)" test and
the following "ev.HasMorePage s = true;" should be _inside_ the "else"
part of the "if (this.m_copy < 3)" test, not outside it.

Your problem with the paper trays may be due to what you're doing with
comboBox1.Selec tedIndex = 4, etc. What are you trying to do there?
Shouldn't there be three combo boxes, so the user can select a paper
source for each of the three copies, or are you trying to do something
else?

Please let me know what the business requirement is behind the combo
boxes. I definitely don't understand.

You're getting close.

I've worked out how to make copy 3 different from the other two. Once
you get this working I'll let you know what you need to change for
that.

Your final requirement, I think, was that you have several of these
invoices (several "reports") to print together in one print job,
whereas right now what you have prints only one, but in three copies,
etc. as we've discussed.

What I'm missing is how you feed the report data into RenderReport. Is
that part of this RenderReport(@" Report PackingList1/Report2") thing?
Is "Report2" the _format_, while "PackingLis t1" the _data_, or am I
confused?

Asked another way, if you render the first invoice in its two different
formats (one with prices, one without) like this:

RenderReport(@" Report PackingList1/Report1");
RenderReport(@" Report PackingList1/Report2");

Then how do you render the second invoice? Is it like this?

RenderReport(@" Report PackingList2/Report1");
RenderReport(@" Report PackingList2/Report2");

If I "don't get it"... please fill me in.

Nov 16 '05 #20

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

Similar topics

3
2724
by: Nick | last post by:
I am working a new application...well actually a series of applications for my company. They want internal users to be able to go to a site and everything regarding security is transparent, however we will have brokers and customers that also need to connect and will require a username and password. In this case we were going to store their credentials in a SQL database. Internal users will have the ability to access the same resources...
1
5855
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure the no funny business can go on in the passed "path" that would produce a path not in the root (i.e. "..\..\dir1"). Here is my first stab at it, but not sure if this is too much or not enouph to ensure this. Any thoughts are welcome. TIA. ///...
13
2553
by: Alison Givens | last post by:
....... that nobody knows the answer. I can't imagine that I am the only one that uses parameters in CR. So, my question again: I have the following problem. (VB.NET 2003 with CR) I have a report with a multiple-value discrete value and a rangevalue. The report shows fine in the viewer, but when I hit the export to pdf
5
1321
by: pjfarley3 | last post by:
Hi all, First-timer here, with a question about composing XML and XSL. I have a need to send one XML file with NO external server references to an end-user browser window; i.e., I would like to be able to do something like having the href in the "xml-stylesheet" declaration be a "local" reference, something like this: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="#Local_xsl"?>
8
5638
by: Mir Nazim | last post by:
Hello, I need to write scripts in which I need to generate all posible unique combinations of an integer list. Lists are a minimum 12 elements in size with very large number of possible combination(12!) I hacked a few lines of code and tried a few things from Python CookBook (http://aspn.activestate.com/ASPN/Cookbook/), but they are hell slow.
3
8211
by: Schroeder, AJ | last post by:
Hello group, I am a relative PHP newbie and I am trying to combine two arrays together, but I also need to keep the keys of one array intact. What I am doing is two SNMP walks against a Cisco router in which I expect the script to return the interface number along with a small description of the interface type, like this: Array (
0
1155
by: shinisen | last post by:
is it possible to combine jsp and asp?
10
1685
by: Terry Olsen | last post by:
I need to be able to write to a file simultaneously from approximately 4 different threads. I'm working on a program that will download parts of a file and combine the parts. Each thread will have an offset from zero and a length to write. None of the threads will overlap in the file position. Is it possible to have the file open (shared) by multiple threads? I'm guessing that i'd use a filestream with some sort of sharing. Looking for...
0
1003
by: Andreas | last post by:
Hi When creating a windows application you get a specific file and folder structure when you compilte your code. I was wondering what sort of control (perhaps not using VS.NET but other tools and command line) I have to influence the way the output is made? At the moment I would get something like this App bin
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.