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:
Code:
...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