私は PODConverter をサービスとして機能させようとしましたが、機能したくありません。面白いことに、正常に動作していた古いバージョンを使用したこと、または少なくとも何かを実行していたとしましょう。soffice.exe がランダムにクラッシュしたため、ここで切り替える必要があります。
そこで、新しいバージョンの JODConverter (jodconverter-core-3.0-beta-4-dist) で新しいテスト プロジェクトを作成しましたが、基本的なビルドはそのままにしました。サービスの引数など。
私のテストプロジェクトはそれほど多くのことをしません。一連の .odt ファイルを別のフォルダーにコピーするだけで、それらを .pdf に変換しようとしますが、何も起こりません。PDFもエラーもありません..何もありません。
これがうまくいかない理由がわからないので、本当に気が狂ってしまうので、皆さんが私を助けてくれることを本当に願っています。
[編集] わかりました、1 つの問題が見つかりました。なぜそれが機能していないのかがわかります。出力が空であるように見えますが、その理由はわかりません。
[EDIT2] エラーが見つかりました.. jar へのパスの一部を忘れました。コード:
Imports System
Imports System.Configuration
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Module Module1
Private OutputMsg As System.Text.StringBuilder = Nothing
Private ErrorMsg As System.Text.StringBuilder = Nothing
Sub Main()
Dim FilesToDelete = Directory.GetFiles("D:\temp")
For Each File In FilesToDelete
System.IO.File.Delete(File)
Next
Dim FilesToConvert = System.IO.Directory.GetFiles("D:\Source", "*.odt", IO.SearchOption.TopDirectoryOnly)
Dim loopCounter As Integer = 0
Dim fileCounter As Integer = 0
Try
For Each file In FilesToConvert
loopCounter += 1
fileCounter += 1
System.IO.File.Copy(file, "D:\temp\" + System.IO.Path.GetFileName(file))
'Prüfe, ob die Blockgröße erreicht ist oder die letzte Datei übertragen wurde!
If fileCounter = FilesToConvert.Count Then
convertFiles()
loopCounter = 0
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub convertFiles()
Try
Dim proc As New Process
proc.StartInfo.WorkingDirectory = "D:\jodconverter-core-3.0-beta-4-dist\jodconverter-core-3.0-beta-4"
proc.StartInfo.FileName = "C:\Program Files (x86)\Java\jre6\bin\java.exe"
proc.StartInfo.Arguments = "java -jar lib/jodconverter-core-3.0-beta-4.jar -o pdf d:\temp\*.odt"
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.RedirectStandardError = True
proc.StartInfo.RedirectStandardInput = True
OutputMsg = New System.Text.StringBuilder()
AddHandler proc.OutputDataReceived, AddressOf OutputHandler
AddHandler proc.ErrorDataReceived, AddressOf ErrorHandler
proc.Start()
proc.BeginOutputReadLine()
proc.WaitForExit()
'Me.SetExitCode(proc.ExitCode)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub OutputHandler(ByVal sendingProcess As Object, _
ByVal outLine As DataReceivedEventArgs)
Try
' Collect the sort command output.
If Not String.IsNullOrEmpty(outLine.Data) Then
' Add the text to the collected output.
OutputMsg.Append(Environment.NewLine + outLine.Data)
Else
MsgBox("Outline is empty!")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub ErrorHandler(ByVal sendingProcess As Object, _
ByVal outLine As DataReceivedEventArgs)
' Collect the sort command output.
If Not String.IsNullOrEmpty(outLine.Data) Then
' Add the text to the collected output.
ErrorMsg.Append(Environment.NewLine + outLine.Data)
Else
MsgBox("Error is empty!")
End If
End Sub
End Module