2
我想将打印预览保存到vb.net中的图像文件。 到目前为止,我的应用程序使用用户提供的文本生成打印预览并打印,但我想将打印的图像保存到我的计算机上。 我已经使用Google,并看到很多答案,如this将打印文档或打印预览保存为vb.net中的图像
但不知何故,它不适合我。任何帮助将不胜感激。
我当前的代码:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim fornt1 As New Font("Arial", 16, FontStyle.Regular)
Dim rect As Rectangle = New Rectangle(New Point(0, 0), PictureBox1.Image.Size)
e.Graphics.DrawImage(PictureBox1.Image, rect) 'Draw Image
e.Graphics.DrawString(RichTextBox1.Text, fornt1, Brushes.LightBlue, 500, 500)
End Sub
End Class