如何在打印PDF之前更改打印机(驱动程序)中的设置?
更具体一点 - 我想强制我的打印机驱动程序使用打印机设置而不是驱动程序默认值 - 基本上相当于单击打印窗口中的属性(打开打印机特定的设置),然后高级设置并勾选“使用打印机设置“默认情况下未选中的复选框。
但它可能是任何东西,例如改变打印机中的抖动模式。
以下是我正在使用的功能代码,用于使用我的网络打印机打印PDF:
Dim PrinterName As String = "\\MyNetwork\ZDesigner ZM400 200 dpi (ZPL)"
Dim WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter(PrinterName)
Dim PrintingPageSettings As New Printing.PageSettings()
Me.Text = PrintingPageSettings.PrinterSettings.PrinterName()
Dim isInstalled As Boolean = False
For Each InstalledPrinter As String In Printing.PrinterSettings.InstalledPrinters()
If (PrintingPageSettings.PrinterSettings.PrinterName() = InstalledPrinter.ToString) Then
isInstalled = True
End If
Next
If (isInstalled) Then
AdobeAcrobatCOM.src = Path
AdobeAcrobatCOM.printAll()
Else
Me.Text = PrinterName & " not found"
End If
AdobeAcrobatCOM是AxAcroPDFLib.AxAcroPDF
(来自Toolbox的Adobe PDF Reader,COM组件)
答案 0 :(得分:0)
最终我使用TCP连接到打印机并以这种方式打印出来。这是一个代码示例:
Dim PrintString As String
Dim ipAddress As String
Dim port As Integer
'123123 is sample integer, "TESTstring" is sample string, Space(2) is sample of adding (two) spaces
PrintString = String.Concat("^XA", "^FO060,080", "^BXN,5,200", "^FD", "TESTstring", 123123, "%^FS", "^FO160,100", "^ACourier,14,14", "^FD", Space(2), "^FS", "^XZ")
ipAddress = "ZDesigner ZM400 200 dpi (ZPL)" 'yes, this works too
port = 9100
'Open Connection
Dim client As New System.Net.Sockets.TcpClient
client.Connect(ipAddress, port)
'Write ZPL String to Connection
Dim writer As New System.IO.StreamWriter(client.GetStream())
writer.Write(PrintString)
writer.Flush()
'Close Connection
writer.Close()
client.Close()
您可能需要查找打印机文档。 Here is a C# example for Zebra