2022年5月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
無料ブログはココログ

« VB.NETからAdobe ReaderでPDFファイルを印刷する。 | トップページ | VBAでZIP圧縮する。 »

2007年11月19日 (月)

VB.NETからAdobe ReaderでPDFファイルを印刷する。(その2)

.NETなら、こんなに簡単です。

Adobe Reader 6.0 ~ 8.1

印刷後、アプリが自動的に終了しないので、終了させます。

PdfPrint.VB

Imports System
Imports System.Diagnostics
Public Class PdfPrint
Public Shared Function Main(ByVal Arguments() As String) As Integer
Dim File As String
For Each File In Arguments
  Dim Process2 As Process=Process.Start("acrord32.exe","/n /p /h """ & File & """")
  Process2.WaitForInputIdle()
  Do
    Process2.CloseMainWindow()
  Loop Until Process2.WaitForExit(1000)
Next
End Function
End Class

お好みで、コンソールコマンドかウィンドウアプリにします。
vbc PdfPrint.VB
または、
vbc /t:winexe PdfPrint.VB

PdfPrint.exe PDFファイル...

« VB.NETからAdobe ReaderでPDFファイルを印刷する。 | トップページ | VBAでZIP圧縮する。 »