更改打印PDF的驱动程序设置



在打印PDF之前,如何更改打印机(驱动程序)中的设置?

更具体地说,我想强制我的打印机驱动程序使用打印机设置,而不是驱动程序默认设置,这基本上相当于在"打印"窗口中单击"属性"(打开打印机特定设置),然后单击"高级设置",勾选"使用打印机设置"复选框,默认情况下不勾选。

但它可以是任何东西,例如改变打印机中的抖动模式。

以下是我现在使用网络打印机打印PDF的功能代码:

Dim PrinterName As String = "\MyNetworkZDesigner 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(工具箱中的Adobe PDF阅读器,COM组件)

最终我使用了与打印机的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()

您可能需要查找打印机文档。以下是Zebra的C#示例。

相关内容

  • 没有找到相关文章

最新更新