全て、
ディスクに書き込まれたpdfファイルを印刷するために使用している次のコードがあります。
Public Function PrintPDF(ByVal PDFFile As String, ByVal Printer As String, ByVal Timeout As Integer) As Integer
log_error.sendEventLog("PrintPDF", "DEBUGGING - Printing PDF. File: " & PDFFile & ". Printer: " & Printer, EventLogEntryType.Information)
If Printer.Trim.Length = 0 Then
Printer = (New System.Drawing.Printing.PrinterSettings).PrinterName
End If
Dim Proc As New System.Diagnostics.Process
Try
Proc.EnableRaisingEvents = True
Proc.StartInfo.FileName = PDFFile
Proc.StartInfo.Arguments = Chr(34) + Printer + Chr(34)
Proc.StartInfo.Verb = "PrintTo"
Proc.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
Proc.StartInfo.CreateNoWindow = True
Proc.Start()
Catch ex As Exception
log_error.sendEventLog("PrintPDF Error", "An issue has occured when attemtping to print a PDF", EventLogEntryType.Error)
End Try
Do While Timeout > 0 AndAlso Not Proc.HasExited
System.Threading.Thread.Sleep(1000)
Timeout -= 1
Loop
If Not Proc.HasExited Then
log_error.sendEventLog("PrintPDF", "Process Killed", EventLogEntryType.Information)
Proc.Kill()
End If
log_error.sendEventLog("PrintPDF", "Process Closed", EventLogEntryType.Information)
Proc.Close()
Proc.Dispose()
Return 0
End Function
この方法を利用するとき、約 10 個の PDF ドキュメントをループしています。これらのドキュメントは、2MB から 5MB の範囲です。何らかの理由で、一部のドキュメントは印刷され、他のドキュメントは印刷されません。ファイルサイズと印刷の成功の間に相関関係はないようです。これは処理中であるため、エラーはスローされていません。
このような前に誰かが問題に遭遇したことがありますか? ご不明な点がございましたら、お知らせください。