是否有任何简单的方式可以使用vb.net进行打印?
具体来说,使用控制台。似乎适用于表单应用程序的东西不适用于控制台。
答案 0 :(得分:6)
取自http://visualbasic.about.com/od/usingvbnet/a/printvb2005.htm
Public Class myPrinter
Friend TextToBePrinted As String
Public Sub prt(ByVal text As String)
TextToBePrinted = text
Dim prn As New Printing.PrintDocument
Using (prn)
prn.PrinterSettings.PrinterName _
= "PrinterName"
AddHandler prn.PrintPage, _
AddressOf Me.PrintPageHandler
prn.Print()
RemoveHandler prn.PrintPage, _
AddressOf Me.PrintPageHandler
End Using
End Sub
Private Sub PrintPageHandler(ByVal sender As Object, _
ByVal args As Printing.PrintPageEventArgs)
Dim myFont As New Font("Microsoft San Serif", 10)
args.Graphics.DrawString(TextToBePrinted, _
New Font(myFont, FontStyle.Regular), _
Brushes.Black, 50, 50)
End Sub
End Class
如下所示:
Dim printer As New myPrinter
printer.prt "Hello World"
答案 1 :(得分:1)
查看PrintDocument
课程。
定义从Windows窗体应用程序打印时将输出发送到打印机的可重用对象。
答案 2 :(得分:0)
好的这篇文章很老但是根据我对这个问题的理解,你想在控制台上打印一个字符串,换句话说:
System.Console.Write("My magnificent string !")
答案 3 :(得分:-2)
我能想到的最简单方法是使用CrystalReports等打印引擎。