Home All Groups Group Topic Archive Search About

How to insert a page break in multi-page document?

Author
19 Jan 2006 3:30 AM
James Wong
Dear all,

For some reason, I have to write my own code to print a document instead of
using report writer.  The source is an array with dynamic length.  If one
page is full, I have to insert a page break and print a new page to
continue.

The following code segment is what I'm using right now.  My question is how
to insert a page break in the middle of the loop since I don't find any
method in PrintDocument similar to this purpose.

Thanks for your attention and kindly help!

James

'>>>  code segment
Private objPrintDoc As PrintDocument
Private arrData() As String

        Private Shared Sub PrnSlip()
                AddHandler objPrintDoc.PrintPage, AddressOf _PrnSlip

                Call objPrintDoc.Print()

                RemoveHandler objPrintDoc.PrintPage, AddressOf _PrnSlip
        End Sub

        Private Shared Sub _PrnSlip(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
                Dim strData As String

                For Each strData In arrData
                    ' loop the array arrData and print
                    ' if page is full, make a page break here and continue
                Next
        End Sub
'>>>

Author
19 Jan 2006 11:58 AM
Peter Huang" [MSFT]
Hi James,

Based on my research, we need to calculate the printed content size and
handle the PrintPage event to Print out our content.
You can take a look at the sample in the MSDN link below.

PrintDocument.PrintPage Event
http://msdn2.microsoft.com/en-us/library/system.drawing.printing.printdocume
nt.printpage.aspx

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.