大致上的作法
把指定的印表機設定成預設印表機
透過Process把PDF檔案開啟、列印
<pre class="c" name="code">
Imports System.Diagnostics
Module Module1
Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal pszPrinter As String) As Boolean
Sub Main()
If SetDefaultPrinter("你的印表機名稱") Then
Dim processInfo As ProcessStartInfo = New ProcessStartInfo("你的PDF檔案路徑")
processInfo.Verb = "print"
processInfo.WindowStyle = ProcessWindowStyle.Hidden
processInfo.CreateNoWindow = True
Dim process As Process = New Process()
process.StartInfo = processInfo
process.Start()
process.WaitForInputIdle()
System.Threading.Thread.Sleep(30000)
If Not process.CloseMainWindow() Then
process.Kill()
End If
Console.WriteLine("Done")
End If
Console.ReadKey()
End Sub
End Module