I have to programmatically create and print multiple documents(Labels). My code creates and prints every label except the first one correctly; which is sent to the default printer, not the specified printer. Does anyone know a fix for this?
Do While ....
txt = sometext
PrintDocument1.Print()
Loop
Private Sub PrintDocument1_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim prFont As New Font("Arial Narrow", 19, FontStyle.Bold)
Dim format As New StringFormat
format.Alignment = StringAlignment.Center
e.PageSettings.PrinterSettings.PrinterName = "\\TLN-CESDC2\TLN2-41-LABEL"
e.PageSettings.Margins.Bottom = 20
e.PageSettings.Margins.Left = 0
e.PageSettings.Margins.Right = 0
e.PageSettings.Margins.Top = 20
e.Graphics.DrawString(txt, prFont, Brushes.Black, 200, 15, format)
End Sub