Link to home
Start Free TrialLog in
Avatar of trbbhm
trbbhmFlag for Afghanistan

asked on

How to Print Multiple Pages using PrintDocument

I have a program in which I want to print a postcard for each record in a datareader control.  Currently I am calling the PrintDocument.Print command after each record is read.  What I would like to do is to create a new "page" for each record and then only call the Print command once.  I've included some code below:

....while reader reads....
Dim custcitystatezip As String
                        Dim prn As New PrintDocument

                        custcitystatezip = StrConv(Trim(Reader("primcity")), VbStrConv.ProperCase)
                        custcitystatezip += ", " & Trim(Reader("primstate"))
                        custcitystatezip += "  " & Trim(Reader("primzipfirst5"))

                        PostcardAddress = custname & vbCrLf & custaddr & vbCrLf & custcitystatezip & vbCrLf & vbCrLf & vbCrLf & Reader("repairnum")

                        AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler
                        Dim ps As System.Drawing.Printing.PaperSource
                        For Each ps In prn.PrinterSettings.PaperSources
                            If ps.SourceName = "Tray2" Then
                                prn.DefaultPageSettings.PaperSource = ps
                                Exit For
                            End If
                        Next
                        prn.DefaultPageSettings.Landscape = True

                        prn.Print()
                        RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler
ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin