我在RichTextBox中打印内容(文本和条形码图像)时遇到问题。 我想循环打印图像和文本。
这是我的richtextbox。
这是我的代码:
Private Sub CreateBarcode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateBarcode.Click
RichTextBox1.AppendText("TEMPORARY MRN - HOSPITAL " & vbNewLine & " MRN : AE - " & Sum.ToString & vbNewLine)
AxBarcode1.Refresh()
Dim img As Image = AxBarcode1.Picture
Dim orgData = Clipboard.GetDataObject
Clipboard.SetImage(img)
Me.RichTextBox1.Paste()
RichTextBox1.AppendText(vbNewLine & " Name : " & vbNewLine & " Ic No : " & vbNewLine & vbNewLine)
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
RichTextBox1.AppendText("TEMPORARY MRN - HOSPITAL " & vbNewLine & " MRN : AE - " & Sum.ToString & vbNewLine)
Dim font As New Font("Arial", 8, FontStyle.Regular)
e.Graphics.DrawString(RichTextBox1.Text, font, Brushes.Black, 10, 10)
AxBarcode1.Refresh()
Dim img As Image = AxBarcode1.Picture
Dim orgData = Clipboard.GetDataObject
Clipboard.SetImage(img)
Me.RichTextBox1.Paste()
e.Graphics.DrawImage(img, 15, 15)
RichTextBox1.AppendText(vbNewLine & " Name : " & vbNewLine & " Ic No : " & vbNewLine & vbNewLine)
e.Graphics.DrawString(RichTextBox1.Text, font, Brushes.Black, 10, 10)
End Sub
以下是输出结果:
感谢并感谢任何帮助:)