Print several pages
-
hi all, I'm playing with the PrintDialog, PrintPreviewDialog and PrintDocument (VB2005 & .Net2.0) so I'm building the document to print on runtime: the user choose some parameters and then the program must print a list of the ones that fits the params. The PrintDocument is build when the
PrintDocument1_PrintPage
event occurs and by inserting Strings and Lines throughe.Graphics.DrawString
ande.Graphics.DrawLine
commands. That's fine (quite tough X|) but I can't manage to add more pages to the document to print. How do I force a new page to fill with data so the document to print would have more than one page? I haven't found the way for changing the page :confused:!!! Thanks in advance, Marc Soleda... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
-
hi all, I'm playing with the PrintDialog, PrintPreviewDialog and PrintDocument (VB2005 & .Net2.0) so I'm building the document to print on runtime: the user choose some parameters and then the program must print a list of the ones that fits the params. The PrintDocument is build when the
PrintDocument1_PrintPage
event occurs and by inserting Strings and Lines throughe.Graphics.DrawString
ande.Graphics.DrawLine
commands. That's fine (quite tough X|) but I can't manage to add more pages to the document to print. How do I force a new page to fill with data so the document to print would have more than one page? I haven't found the way for changing the page :confused:!!! Thanks in advance, Marc Soleda... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
For starting a new page, you will need to set e.HasMorePages property to True and exit the PrintPage event. If this property is set to true while exiting sub, this event will be called again and its content will be printed on the next page. Therefore it should be something like – e.HasMorePages = True Exit Sub Please remember that you will need to track manually when this event is being called for the second time and what you need to print on the second page. This can be done using a global variable. Such as – ----------------------Code Start--------------- Dim PageCount As Integer = 1 Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage If PageCount = 1 Then ''''Code to print on first page e.HasMorePages = True PageCount += 1 Exit Sub ElseIf PageCount = 2 Then ''''Code to print on Second Page e.HasMorePages = True PageCount += 1 Exit Sub End If End Sub ------------------Code End------------------- In the similar way you may create any number of new pages. I hope this helps :) . -Dave.
Dave Traister, ComponentOne LLC. www.componentone.com
-
For starting a new page, you will need to set e.HasMorePages property to True and exit the PrintPage event. If this property is set to true while exiting sub, this event will be called again and its content will be printed on the next page. Therefore it should be something like – e.HasMorePages = True Exit Sub Please remember that you will need to track manually when this event is being called for the second time and what you need to print on the second page. This can be done using a global variable. Such as – ----------------------Code Start--------------- Dim PageCount As Integer = 1 Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage If PageCount = 1 Then ''''Code to print on first page e.HasMorePages = True PageCount += 1 Exit Sub ElseIf PageCount = 2 Then ''''Code to print on Second Page e.HasMorePages = True PageCount += 1 Exit Sub End If End Sub ------------------Code End------------------- In the similar way you may create any number of new pages. I hope this helps :) . -Dave.
Dave Traister, ComponentOne LLC. www.componentone.com
Great, it's what I was looking for. Thanks, Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits