|
-
September 1st, 2009, 02:17 PM
#1
Why does Print Preview show properly formatted pages that won’t actually print?
I am writing an app to print formatted data using NET3.5 / VS 2008. I am using two Print Documents and event handlers, because the first page of the report carries formatting requirements that differs from pages 2 through N.
The Print Previews show me properly formatted data for all pages that I try to print. Nevertheless, pages 2 through N will not actually print. Can anyone shed some light on what I might be doing wrong?
This is the code that creates the print documents and event handlers. It also calls the print preview dialog and gives the command to print.
// Create an event handler for the Print Page Event
OrdersPrintDocument.PrintPage += new PrintPageEventHandler(this.OrdersPrintDocument_PrintPage);
// Creating a second event handler to print overflow Item pages
ItemsPrintDocument.PrintPage += new PrintPageEventHandler(this.ItemsPrintDocument_PrintPage);
// Getting a look at my formating
PrintPreviewDialog printPreview = new PrintPreviewDialog();
printPreview.Document = OrdersPrintDocument;
printPreview.ShowDialog();
// Print the document
OrdersPrintDocument.Print();
// Reset the item counts so a subsequent order to print will
// begin at zero.
iItemPrintedCount = 0;
This is the section that calls the second print document's event handler.
// We've reached our page limit for printed items. Do we
// still have unprinted items in the arraylist? Call the second
// print handler event and print those items.
if (((alItemsToPrint.Count) - iItemPrintedCount) > 0)
{
// Getting a look at my formating
PrintPreviewDialog printPreview2 = new PrintPreviewDialog();
printPreview2.Document = ItemsPrintDocument;
printPreview2.ShowDialog();
// Print item overflow pages
ItemsPrintDocument.Print();
}
Here is the segment for iterating and printing pages 2 through N.
int iIterateAgain = 0;
iIterateAgain = (alItemsToPrint.Count) - iItemPrintedCount;
// We've reached our page limit for printed items, Do we
// still have unprinted items in the arraylist? Re-call the second
// print handler event and print those items.
if (iIterateAgain > 0)
{
EventArgs.HasMorePages = true;
}
I can show the code in between if necessary, but maybe this is enough to for someone point out where I've fallen down.
Thanks!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|