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

Changing driver settings for printing a PDF

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

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

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

这是我现在使用的功能代码,用于使用我的网络打印机打印 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(来自工具箱的 Adob​​e PDF Reader,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()

您可能需要查找您的打印机文档。 Here is a C# example for Zebra.