如何在VB.NET中加速打印?
问题描述:
我有一些打印代金券的代码,工作正常。问题是它需要2/3秒才能开始打印,但我的客户想要快速打印。我正在显示代码,请帮助
这是我的代码
I have some code for printing vouchers, working fine. Problem is it's taking 2/3 seconds to start print, but my customer wants fast print. am showing code, please help
here is my code
Private Sub Btn_Print_Test_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Print_Test.Click
Me.Btn_Print_Test.Enabled = False
Dim document As New PrintDocument
AddHandler document.PrintPage, New PrintPageEventHandler(AddressOf Me.TestPrint_PrintPage)
document.PrintController = New StandardPrintController
document.Print()
Me.Btn_Print_Test.Enabled = True
End Sub
Private Sub TestPrint_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
e.Graphics.DrawString("* 012345678987654*", New Font("Free 3 of 9 Extended", 17.0!, FontStyle.Regular), Brushes.Black, CSng(2.0!), CSng(0.0!))
e.Graphics.DrawString("* 012345678987654*", New Font("Free 3 of 9 Extended", 17.0!, FontStyle.Regular), Brushes.Black, CSng(2.0!), CSng(17.5!))
e.Graphics.DrawString(Strings.Space(10) & "* 012345678987654 *", New Font("Courier", 8.0!, FontStyle.Regular), Brushes.Black, CSng(2.0!), CSng(38))
End Sub
我尝试了什么:
我搜索了很多相关的教程打印,但没有任何帮助我
What I have tried:
I have searched so many tutorials related printing, but nothing helped me
答
问题是你正在处理Windows Print Spooler。你做的绘图工作排队,而不是直接打印。打印机驱动程序必须将绘图命令转换为打印机理解的语言来描述页面图像,然后必须将数据发送到打印机。通常情况下,您实际上是将大量描述页面图像的数据发送给打印机。
没有办法加快速度。
您唯一的选择就是以打印机理解的语言绕过假脱机程序直接将文本和图像发送到打印机。这个问题是您必须学习打印机的语言并编写大量代码来自行描述和布局文本和图像,将所有内容转换为打印机理解的语言。您的代码也只支持理解相同语言的打印机,限制您的打印机选项。
The problem is you're dealing with the Windows Print Spooler. The drawing stuff you do gets queued up, not directly printed. The printer driver has to convert your drawing commands into the language the printer understands to describe the page image, then that data has to be sent to the printer. Normally, you're actually sending LOTS of data that describe the page image to the printer.
There is no way to speed this up.
You're only option is to send your text and images to the printer directly, bypassing the spooler, in the language the printer understands. The problem with this is you have to learn the language of the printer and write a ton of code to describe and layout the text and images yourself, converting everything to the language the printer understands. You're code will also only support printers that understand the same language, limiting your printer options.