For instance, I have a single label to print like below example, now if I want to make 3 copies of it, How can I print the copy number somewhere in the label I’m printing?
Sample code:
Private Sub btnPrintProcLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintProcLabel.Click
If ValidateData() Then
AddHandler PrintDocument1.PrintPage, AddressOf PrintProcLabel
Try
PrintDocument1.PrinterSettings.PrinterName = SinglePrinter.PrinterSettings.PrinterName
PrintDocument1.PrinterSettings.Copies = CInt(txtCopies.Text)
PrintDocument1.Print()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
Public Sub PrintProcLabel(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim g As Graphics = e.Graphics
Dim br As Brush = New SolidBrush(Color.Black)
Dim pn As Pen = New Pen(br)
g.DrawString(Today.Month & "/" & Today.Day & "/" & Today.Year, Arial, br, 250, 3)
End Sub
That tells the printer driver to generate the copies, they will all be identical. If you want to number them then you’ll need to create the “copies” yourself. They are not really copies anymore since they’ll all be slightly different. Just call the Print() method repeatedly, using a counter whose value you DrawString() in your PrintPage event handler.